<!DOCTYPE html>
<html lang="">
<!-- 在index.html中 -->
<!-- 没有看到引入main.js文件的原因是Vue脚手架会自动找到main.js文件并引入,不需要手动引入 -->
<!-- 因此在一般情况下,我们不要轻易修改main.js所在的位置和文件名 -->
<!-- 如果真的要修改,需要在vue.config里面修改对应的配置信息 -->
<head>
<meta charset="utf-8">
<!-- 让IE浏览器启用最高渲染标准,IE8不支持VUE -->
<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><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<!-- 当浏览器不支持JS语言的时候,显示如下的信息 -->
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<!-- VUE管理的容器 -->
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<!-- 使用组件 -->
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
</template>
<script>
// 导入组件
import HelloWorld from './components/HelloWorld.vue'
export default {
// 设置vue开发者工具中显示的组件名
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>
// 这句话就等同于我们写的<script src="vue.js">
// 这就是在引入vue
import Vue from 'vue'
// 然后下一步是导入我们的根组件
import App from './App.vue'
// 这是关闭生产提示信息
Vue.config.productionTip = false
// 创建VUE实例对象VM
new Vue({
render: h => h(App),
}).$mount('#app');
// 这里用的是$mount的方式绑定和el的方式是一样的