我正在尝试不带导轨的涡轮驱动器。
它似乎适用于表单但不适用于链接..即使表单设置为GET
.
为了尽量减少它,我使用了 bash 和 cgi,但是我在使用另一个 Web 框架时看到了同样的东西。
$ mkdir example
$ cd example
$ cat > index.html
<meta http-equiv="Refresh" content="0; url='/cgi-bin/index.sh'" />
$ mkdir cgi-bin
$ cat > cgi-bin/index.sh
#! /usr/bin/env bash
set -e
echo Content-Type: text/html
echo
sed "s/NEW/$RANDOM/g" << EOF
<html>
<head>
<title>DEMO</title>
<script src="/node_modules/@hotwired/turbo/dist/turbo.es2017-umd.js"></script>
</head>
<body>
<h1>DEMO</h1>
<h2>$QUERY_STRING</h2>
<a href="?val=NEW">NEW</a>
<form action="?">
<input type="hidden" name="val" value="NEW" />
<input type="submit" />
</form>
</body>
</html>
EOF
$ chmod +x cgi-bin/index.sh
$ npm install --save @hotwired/turbo@7.0.1
$ python3 -m http.server --cgi # or whichever server
然后当我去http://localhost:8000
我得到这个:
链接和提交按钮都加载链接中显示的随机数,并准备一个新的随机数进行加载。
不同之处在于链接会重新加载整个页面,就好像不包括涡轮增压器一样,并且会获取表单。
我该怎么做才能使它也成为 ajax 链接?我是否忽略了链接中需要的属性或其他内容?