1
在下面的代码中,标记为的按钮添加更多未按预期运行。理想情况下,它应该将输入值添加到页面上的无序列表中。相反,我得到以下错误:错误:document.queryselector不是函数
Uncaught TypeError: document.queryselector is not a function
页代码
<div id="root">
<input type="text" id="input" v-model="message"/>
<p>The value of the input is : {{message}}</p>
<ul>
<li v-for="n in names" v-text="n"></li>
</ul>
<input id="input1" type="text"/>
<button id="button"> Add More </button>
</div>
<script>
var app = new Vue ({
el : '#root',
data : {
message : 'Hello World!',
favourite : 'author',
names : ['Sunil' , 'Anis' , 'Satyajit']
},
});
document.queryselector('#button').addEventListener('click', function(event) {
var n = document.queryselector('#input1');
app.names.push(n.value);
n.value = '';
});
</script>
谢谢。我已纠正它。它仍然不起作用。 –
@SFDC_Learner是否在意扩展?你仍然得到querySelector不是一个函数? – Bert
请发现我已经更新了移除安装部件的代码。它仍然没有工作,并说下面的错误。 –