template用双引号还是报错
来源:1-6 组件概念初探,对 TodoList 进行组件代码拆分

杨洋洋
2021-07-13
<script>
Vue.createApp({
data() {
return {
inputValue: '',
list: []
}
},
methods: {
handleAddItem() {
this.list.push(this.inputValue);
this.inputValue = '';
}
},
template: "
<div>
<input type='text' v-model='inputValue'>
<button v-on:click='handleAddItem'>增加</button>
<ul>
<li v-for='(item, index) of list'>{{item}} {{index}}</li>
</ul>
</div>
"
}).mount('#root')
</script>
写回答
1回答
-
杨洋洋
提问者
2021-07-13
知道了,原来是要用`
```
template: `
<div>
<input type='text' v-model='inputValue'>
<button v-on:click='handleAddItem'>增加</button>
<ul>
<li v-for='(item, index) of list'>{{item}} {{index}}</li>
</ul>
</div>
`
```
00
相似问题