【发布时间】:2017-12-15 08:24:49
【问题描述】:
我有一个创建照片的项目。我希望每张照片都是一个 vue 组件。
我发送了一个 axios 请求,在回答之后我想一张一张地插入每张照片,但每张照片必须是一个 vue 组件。
axios.get('/api/prepare?query='+encodeURIComponent(this.text))
.then(function(result){
const result_data = result.data;
self.images = result_data.images;
let index = 0;
for(let image in result_data.images){
new Vue({
el : "#photo",
template : "Photo.vue",
data : {
src : result_data.images[image].src,
symbolId : image,
photoId : result_data.images[image].photo_id,
name : index
}
});
index++;
}
在我的模板中我有<div id="photo"></div>
但我在控制台中遇到错误
找不到元素:#photo
【问题讨论】:
标签: vue.js