【发布时间】:2018-06-21 21:18:06
【问题描述】:
我想从一个 var 的外部 JSON 文件中获取数据。我认为问题在于我使用 in-html vue.js 和 Vue.js 不明白我为他写的内容:joy:
jsfiddle
第二个问题是我不能使用来自 json 的值:
new Vue({
el: '#app',
data() {
return {
searchResult: [],
search: '',
}
},
created: function() {
this.searchResult = [
{
"id": 0,
"title": "d",
"img": "src"
}
];
},
computed: {
filteredName: function() {
return this.searchResult.filter((x) => {
return x.title.match(this.search)
});
},
allOK: function () {
if (this.search.valueOf() === "") {
return false
} else {
return true
}
},
hrefResult: function () {
return "/item?=" + this.searchResult.id
}
}
});
我要做什么? :(
【问题讨论】:
-
我在 HTML 文件中使用 Vue.js
标签: javascript html css json vue.js