This is a simple demo for creating vue project using npm (rather than directly introduce vue.min.js
), and using the "single-file component (SFC)" style.
Each step in the following (git commands are omitted) corresponds to one commit of the git repo, so you can see the changes after each step.
Run:
npm init
and input the information.
Run:
npm install --save [email protected]
npm install --save-dev [email protected] [email protected] [email protected] [email protected]
The source files index.html
, main.js
, app_1.vue
are prepared in SFC style.
The file configures the webpack.
Run (for Windows):
.\node_modules\.bin\webpack
to pack the sources, and get a bundle file.
A simple way to build a server to launch the app is using python's server. Run:
python -m http.server 8888
Then the app can be visited by a browser at
http://localhost:8888/
A "recursive_node" component recursively contains itself, so we can print a tree.
reference: 《vue组件递归》.
Run:
npm install --save-dev [email protected] [email protected]
Modify the webpack.config.js
to add a rule to load CSS style.
{
test: /\.css$/,
use:['style-loader','css-loader']
}
Then, add styles in .vue
file, and finally run webpack.