
3.vue3项目结构
3.vue3项目结构
3.1.main.js
//引入的不再是Vue的构造函数,引入的是一个名为createApp的工厂函数
import { createApp } from 'vue'
import App from './App.vue'
// createApp(App).mount('#app')
//创建应用实例对象-app(类似于Vue2中的vm,但app比vm更‘轻’)
const app = createApp(App)
//挂载
app.mount('#app')
3.2.关闭语法检查
vue.config.js
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
//关闭语法检查
lintOnSave: false,
transpileDependencies: true
})
3.3.App.vue
<template>
<!--vue3的组件中的模板结构可以没有根标签-->
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'App',
components: {
HelloWorld
}
}
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果