您可以使用国内的CDN源来加载Vue.js库,例如使用国内非常流行的CDN服务提供商“jsDelivr”的中国镜像。以下是使用国内源的Vue.js CDN链接:
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
请注意在上面的URL中,我给出了一个特别的版本号(2.6.14)作为示例,您可以根据需要替换成最新的稳定版本。
以下是改用国内源后的更新页面代码:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>替换词</title>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
</head>
<body>
<div id="app">
<form @submit.prevent="submitForm">
<label for="searchTerm">替换前词:</label>
<input type="text" v-model="searchTerm" id="searchTerm" placeholder="输入要替换的词" required>
<br>
<label for="replaceTerm">替换后词:</label>
<input type="text" v-model="replaceTerm" id="replaceTerm" placeholder="输入替换后的词" required>
<br>
<button type="submit">提交</button>
<button type="button" @click="clearFields">清空</button>
</form>
<div v-if="message">{{ message }}</div>
</div>
<script>
new Vue({
el: '#app',
data: {
searchTerm: '王bao强',
replaceTerm: '王宝强',
message: ''
},
methods: {
submitForm() {
const urls = [
`http://yourdomain.com/update_sql.php?type=title&searchTerm=${encodeURIComponent(this.searchTerm)}&replaceTerm=${encodeURIComponent(this.replaceTerm)}`,
`http://yourdomain.com/update_sql.php?type=content&searchTerm=${encodeURIComponent(this.searchTerm)}&replaceTerm=${encodeURIComponent(this.replaceTerm)}`,
`http://yourdomain.com/update_sql.php?type=content_fmt&searchTerm=${encodeURIComponent(this.searchTerm)}&replaceTerm=${encodeURIComponent(this.replaceTerm)}`
];
const requests = urls.map(url => fetch(url));
Promise.all(requests)
.then(responses => {
return Promise.all(responses.map(response => response.text()));
})
.then(results => {
this.message = '更新成功!';
})
.catch(error => {
this.message = '错误:' + error.message;
});
},
clearFields() {
this.searchTerm = '';
this.replaceTerm = '';
this.message = '';
}
}
});
</script>
</body>
</html>
请记得将 yourdomain.com
替换成您自己的网站域名,并确保您的服务器上的 PHP 脚本能够处理异步请求。