【发布时间】:2018-08-13 12:21:02
【问题描述】:
我正在关注 Vue.js 文档并运行 this example。
所以这里是 index.html 文件:
<html>
<head>
<link rel="stylesheet" href="index.css">
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<h1>Bitcoin Price Index</h1>
<div v-for="currency in info" class="currency" >
{{ currency.description }}:
<span class="lighten">
<span v-html="currency.symbol"></span>
{{ currency.rate_float | currencydecimal }}
</span>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
这里是 index.js:
new Vue({
el: '#app',
data () {
return {
info: null
}
},
mounted () {
axios
.get('https://api.coindesk.com/v1/bpi/currentprice.json')
.then(response => (this.info = response.data.bpi))
},
filters: {
currencydecimal (value) {
return value.toFixed(2)
}
},
})
输出:
(您可以将上面的代码复制粘贴到here)
问题:在index.html,我不明白{{ currency.description }} 来自哪里。 currency 甚至没有在 Vue() 实例的 data 中声明。
【问题讨论】: