我已经使用vue-cli @ 4创建了一个项目,并且可以正常工作,但是我对main.js进行了一些更改,但是它不再起作用了。
//main.js
import Vue from "vue";
import App from './App.vue'
//Vue.config.productionTip = false;
new Vue({
el: "#root-app",//commented components property when using render and mount
components: {
App
},data: {
name: "amandeep Singh"
}
// render: h => h(App),}); //.$mount('#app')
App.vue文件
<template>
<div>
testingggg
<img alt="Vue logo" src="./assets/logo.png">
</div>
</template>
<script>
export default {
name: 'app',}
</script>
Index.html文件
<!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">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>admin</title>
</head>
<body>
<div id="root-app">
{{name}}
<app></app>
</div>
<!-- built files will be auto injected -->
</body>
</html>
即使没有插入“名称”值,也没有显示任何内容。 但是,如果我取消评论
渲染:h => h(App),
和
。$ mount('#app')
一切正常。 所以我的问题为什么不对这两个进行评论。我检查了许多示例,看到了一些项目,这些项目不需要使用渲染功能,它们使用的只是“ el”属性,可将vue挂接到Html,并且一切正常。
所以有人可以请问这里发生了什么?我做错了什么? 如何在不进行渲染和挂载的情况下进行工作,为什么有必要?