开发是用到 -Dcss
安装babel插件html
1: 运行 cnpm i @babel/core babel-loader @babel/plugin-transform-runtime -D 转换工具前端
2: 运行 cnpm i @babel/preset-env @babel/preset-stage-0 -D 语法vue
3: 安装可以识别转换jsx语法的包 babel-preset-reactnode
运行 cnpm i @babel/preset-react -Dreact
4: 执行命令:cnpm i @babel/plugin-proposal-class-properties -Djquery
5: 执行命令:cnpm i @babel/runtime -Dwebpack
9: Vue组件
npm i vue-loader vue-template-compiler -Dgit
10: vue-routergithub
npm i vue-router -S
上面的作法是 Babel^6x 版本的使用方法,babel在2018年9月份升级了一个大的版本 Babel 7.x,语法有了很大的变更,因此我上面运行的指令已经被out了,必须使用新语法,以下:
新命令以下适合 Babel 7.x和webpack 4 搭配:
{ test:/\.js$/, use: 'babel-loader', exclude: /node_modules/ } //配置 babel 转化ES6 语法
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
解决办法:
解决办法:
2:直接修改 main 属性
3:导入vue,在webpack.config.js中修改引用指向
npm i vue-router -S
1:导包:
2:绑定路由对象
1:main.js不支持
import $ from 'jquery'
2: webpack ./src/main.js ./dist/bundle.js
这个时候导入的是物理磁盘上的bundle.js
2.2:配置入口函数和出口函数,还有mode。这个时候使用webpack命令,导入的仍是bundle.js
2.3:使用webpack-dev-server 这个工具导入的是webpack-dev-server生成在根路径中的bundle.js是在内存中。
// 这里简单说一下安装命令的简写和规范
// i => install
// -D => --save-dev
// -S => --save
// -S 会安装到 dependencies 属性下
// -D 安装到 devDependencies 属性下
// 规范是,-S 安装项目中会用到的代码,例如 vue、react、lodash 等
// -D 安装构建代码,不会在项目代码中使用,例如 webpack、css-loader 等
3: render和路由