学习VUE中name不显示!是什么原因
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/jacascript" src="../vue.js/vue.js"></script>
<title>Document</title>
</head>
<body>
<div id="root"></div>
<h2 v-show="true">{{name}}</h2>
</body>
<script type="text/jacascript">
Vue.config.productionTip = false
new Vue({
el:'root',
data:{
name:'hello'
}
})
</script>
</html>
运行结果
实例没有注册成功,检查el问题
<body>
<div id="app">
{{ counter }}
</div>
<script>
const App = {
data() {
return {
counter: 0
}
}
};
Vue.createApp(App).mount('#app');
</script>
</body>
你要把代码包裹在你创建的实例中
不知道你这个问题是否已经解决, 如果还没有解决的话: