构建项目
- 项目入口(index.html)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>sell</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
备注:
id = “app”
- js解析入口
src/main.js
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue' //导入vue 信息
import App from './App' //导入自定义App.vue文件
import router from './router' //导入路由
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
el: '#app', //绑定vue的作用域
router, //使用的路由
template: '<App/>', //模板
components: { App } //组件
})
- 组件文件 App.vue
<template>
<div id="app">
<img src="./assets/logo.png">
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'app'
}
</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>
组件 ,