# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
Name | Version | Description |
---|---|---|
Loads and compiles Vue Components | ||
Loads ES2015+ code and transpiles to ES5 using Babel | ||
Loads and compiles a SASS/SCSS file | ||
a bundler for modules. bundle JavaScript files for usage in a browser | ||
3.0.3 | AlipayJSAPI 提供丰富的支付宝原生 API,可以方便调用支付宝提供的能力,达到媲美原生应用的体验。 | |
aliyun |
- js、css、html 文件名全部小写,单词用下划线 “_” 连接
hello_world.js
- vue组件的name属性首字母大写
export default {
name:"HelloWorld"
}
- scss文件中使用@import时 需要把后缀名写全,并带上注释
@import "hello_world.scss";//hello_world组件用的样式
- 所有的接口地址写在apis_map.js文件中,带参数的地址可以用花括号表示
let map={
"api":"/hello/world",
"test":"/api/helloworld/{name}"
}
apis_map.js中存放所有的接口地址,在组件中使用this.$api访问,访问带未解析参数的地址会报错
// in apis_map.js
let map={
"test":"/api/helloworld/{name}"//这个地址有未解析的参数
}
//...
//in vue component
this.$api.test //会输出异常 不能直接使用带未解析参数的地址
Api对象提供一个resolve方法用来解析带参数的地址
// in apis_map.js
let map={
"test":"/api/helloworld/{name}"
}
//...
//in vue component
this.$api.resolve("test","peter") //return "/api/helloworld/peter"
/*
* @param {String} key api地址的名字
* @param {String} * 可以传入任意数量的参数 需要和api地址中未解析的参数个数保持一致
*/
this.$apis.resolve(key,param1,param2,...n)