[Vue warn]: Cannot find element: #app
代码很简单,如下所示<!DOCTYPE html><html><head><meta charset="UTF-8"><title></title><script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js" type="text/java...
·
代码很简单,如下所示
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
var Vm = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
</script>
</head>
<body>
<div id="app">
{{message}}
</div>
</body>
</html>
一直以为是引入的vue.js有问题换了好多,然后又配置npm
原来是手写的vue.js要在最后引入
因为要先有id为vue-app的div,vue才能获取相应的元素。
更改后:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="app">
{{message}}
</div>
</body>
<script type="text/javascript">
var Vm = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})
</script>
</html>
更多推荐
已为社区贡献1条内容
所有评论(0)