1.创建项目(xxx为项目名)vue create -p dcloudio/uni-preset-vue xxx
2.安装uview UI框架 npm install uview-ui@1.8.4
1) npm i node-sass
2) npm i sass-loader@10.1.1 --save-dev (指定版本 否则报错cache-loader not found)
引入uview
main.js
1) import uView from "uview-ui";
2) Vue.use(uView);
uni.scss
1) @import 'uview-ui/theme.scss';
app.vue(答应我一定加上lang='scss',没仔细看 找了好久!)
2)@import "uview-ui/index.scss";
pages.json
"easycom":{"^u-(.*)":"uview-ui/components/u-$1/u-$1.vue"},
创建vue.config.js
const TransformPages = require('uni-read-pages')
const {webpack} = new TransformPages()
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = {
configureWebpack: {
plugins: [
new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'aliasPath']
});
return JSON.stringify(tfPages.routes)
}, true )
})
]
}
}
uview引入完毕,页面内使用一下组件吧!
3.安装uni-simple-router 路由插件(可用可不用,我是习惯用的)
https://hhyang.cn/v2/start/quickstart.html 官方文档,有点懒,直接看官方的吧
安装好之后 console.log(this.$Router) 能打印出来就代表安装成功了,接下来就是看官方文档了~
至此,基本结束,想到的再补充