Comments (2)
试了下,在本地没法复现出来。
结合源码,我感觉是上面两个 CDN 的资源由于众所周知的原因没有加载进来。
用某些工具试一下呢?或者将它复制到本地,把 CDN 换成能访问的(比如 bootcdn.cn),此时需要把 Vue 这个依赖也给加上。
from v2.cn.vuejs.org.
应该是 @dev-itsheng 所说的问题,对国内网络来说,使用BootCDN会好一些😉。
new.mp4
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="watch-example">
<p>
Ask a yes/no question:
<input v-model="question">
</p>
<p>{{ answer }}</p>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.js"></script>
<!-- 因为 AJAX 库和通用工具的生态已经相当丰富,Vue 核心代码没有重复 -->
<!-- 提供这些功能以保持精简。这也可以让你自由选择自己更熟悉的工具。 -->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.12.0/axios.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/lodash.js/4.13.1/lodash.min.js"></script>
<script>
var watchExampleVM = new Vue({
el: '#watch-example',
data: {
question: '',
answer: 'I cannot give you an answer until you ask a question!'
},
watch: {
// 如果 `question` 发生改变,这个函数就会运行
question: function (newQuestion, oldQuestion) {
this.answer = 'Waiting for you to stop typing...'
this.debouncedGetAnswer()
}
},
created: function () {
// `_.debounce` 是一个通过 Lodash 限制操作频率的函数。
// 在这个例子中,我们希望限制访问 yesno.wtf/api 的频率
// AJAX 请求直到用户输入完毕才会发出。想要了解更多关于
// `_.debounce` 函数 (及其近亲 `_.throttle`) 的知识,
// 请参考:https://lodash.com/docs#debounce
this.debouncedGetAnswer = _.debounce(this.getAnswer, 500)
},
methods: {
getAnswer: function () {
if (this.question.indexOf('?') === -1) {
this.answer = 'Questions usually contain a question mark. ;-)'
return
}
this.answer = 'Thinking...'
var vm = this
axios.get('https://yesno.wtf/api')
.then(function (response) {
vm.answer = _.capitalize(response.data.answer)
})
.catch(function (error) {
vm.answer = 'Error! Could not reach the API. ' + error
})
}
}
})
</script>
</body>
</html>
from v2.cn.vuejs.org.
Related Issues (20)
- Vue 3 Docs are ready for translation! HOT 2
- components.md-动态组件-示例代码:频繁切换home/posts/archive会使页面scroll down HOT 1
- "export 'default' (imported as 'Vue') was not found in 'vue'
- 小疑惑 HOT 4
- Vue 不能检测以下数组的变动:通过索引或长度改变数组。有歧义
- 关于中文站跳转的建议(仅针对中文站) HOT 2
- select option v-for 出错 HOT 1
- component 标签动态事件
- 教程 -> 组件基础 -> 监听子组件事件 -> 在组件上使用 v-model 菜单对应的地址被重定向到了错误的页面
- “v2.x中文文档->深入了解组件->动态组件 & 异步组件” 中存在病句
- vue2的选项框,多选不起作用 HOT 1
- amazing url, refresh forever HOT 3
- v-if与v-for一起使用时的介绍错误 HOT 1
- website error for cn.vuejs.org HOT 5
- API list not found for cn.vuejs.org/v2/api/ HOT 1
- 标题:在 v-for 里使用范围,是否翻译不当?
- https://v2.cn.vuejs.org/ 搜索功能失效,跳转地址错误 HOT 3
- Vue.config.productionTip = false 无效 HOT 2
- Inaccuracy in comparisons guide
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from v2.cn.vuejs.org.