1. Import existing resources
Background project is relatively complex, we do not build the project from zero, but direct use of ready source.
We decompression, into the working directory: E: \ javaProject \ JavaEEProject
Open the project can use idea.
First open the directory structure:
2.
3. Run it and see
4. Directory Structure
-
index.html: html template file. It defines empty
div
, with idapp
. -
main.js:实例化vue对象,并且通过id选择器绑定到index.html的div中,因此main.js的内容都将在index.html的div中显示。main.js中使用了App组件,即App.vue,也就是说index.html中最终展现的是App.vue中的内容。index.html引用它之后,就拥有了vue的内容(包括组件、样式等),所以,main.js也是webpack打包的入口。
-
index.js:定义请求路径和组件的映射关系。相当于之前的
<vue-router>
-
App.vue中也没有内容,而是定义了vue-router的锚点:
<router-view>
,我们之前讲过,vue-router路由后的组件将会在锚点展示。 -
最终结论:一切路由后的内容都将通过App.vue在index.html中显示。
-
访问流程:用户在浏览器输入路径,例如:http://localhost:9001/#/item/brand