当前位置:网站首页>在uni-app中引入uView
在uni-app中引入uView
2022-07-02 05:54:00 【Serena_tz】
在uni-app中引入uView的方式有两种:
通过npm下载
// 如果您的根目录没有package.json文件的话,请先执行如下命令:
// npm init -y
npm install uview-ui
// 更新
// npm update uview-ui
配置步骤
1.引入uView主JS库
在项目根目录中的main.js中,引入并使用uView的JS库,注意这两行要放在import Vue之后。
// main.js
// 引入全局 uView 框架
import uView from 'uview-ui';
Vue.use(uView);
2.在引入uView的全局SCSS主题文件
在项目根目录的uni.scss中引入此文件。
/* uni.scss引入view主题样式 */
@import 'uview-ui/theme.scss';
3.引入uView基础样式
注意:在App.vue中首行的位置引入,注意给style标签加入lang="scss"属性
<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
</style>
4.配置easycom组件模式
在pages.json配置,uni-app为了调试性能的原因,修改easycom规则不会实时生效,配置完后,您需要重启Hbuilder X或者重新编译项目才能正常使用uView的功能。请确保您的pages.json中只有一个easycom字段,否则请自行合并多个引入规则。
"easycom": {
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
通过插件市场安装
如果使用Hbuilder X进行开发,就可以在uni-app插件市场通过uni_modules的形式进行安装。
1.点击导入
2.打开hbuilderX
3.选择项目
4.开始下载
5.确保安装了scss/sass编译器
在工具中找到“插件安装”

配置步骤
1.引入uView主JS库
在项目根目录中的main.js中,引入并使用uView的JS库,注意这两行要放在import Vue之后。
// main.js
import uView from '@/uni_modules/uview-ui'
Vue.use(uView
2.在引入uView的全局SCSS主题文件
在项目根目录的uni.scss中引入此文件。
/* uni.scss */
@import '@/uni_modules/uview-ui/theme.scss';
3.引入uView基础样式
注意:在App.vue中首行的位置引入,注意给style标签加入lang="scss"属性
<style lang="scss">
/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
@import "@/uni_modules/uview-ui/index.scss";
</style>
4.配置easycom组件模式
在pages.json配置,uni-app为了调试性能的原因,修改easycom规则不会实时生效,配置完后,您需要重启Hbuilder X或者重新编译项目才能正常使用uView的功能。请确保您的pages.json中只有一个easycom字段,否则请自行合并多个引入规则。uni_modules方式引入的uview可以不配置。
"easycom": {
"^u-(.*)": "@/uni_modules/uview-ui/components/u-$1/u-$1.vue"
},
边栏推荐
- php数组转化为xml
- ESP8266与STC8H8K单片机联动——天气时钟
- mysql事务和隔离级别
- PHP 开发与测试 Webservice(SOAP)-Win
- Yyds dry inventory what is test driven development
- The Hong Kong Stock Exchange learned from US stocks and pushed spac: the follow-up of many PE companies could not hide the embarrassment of the world's worst stock market
- token过期自动续费方案和实现
- 2022-2-14 learning xiangniuke project - Section 7 account setting
- 460. LFU 缓存 双向链表
- Redis Key-Value数据库 【高级】
猜你喜欢

Eco express micro engine system has supported one click deployment to cloud hosting

all3dp.com网站中全部Arduino项目(2022.7.1)

测试 - 用例篇

文件包含漏洞(一)

MySQL transaction and isolation level

Gcnet: non - local Networks meet Squeeze excitation Networks and Beyond

ThreadLocal memory leak

Stick to the big screen UI, finereport development diary

2022-2-15 learning xiangniuke project - Section 8 check login status

Vite打包后的dist不能直接在浏览器打开吗
随机推荐
"Simple" infinite magic cube
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
Thread pool overview
Zzuli:1068 binary number
Happy Lantern Festival | Qiming cloud invites you to guess lantern riddles
idea开发工具常用的插件合集汇总
RNN recurrent neural network
mock-用mockjs模拟后台返回数据
STC8H8K系列汇编和C51实战——数码管显示ADC、按键串口回复按键号与ADC数值
Matplotlib double Y axis + adjust legend position
Software testing - concept
使用sha256文件验证下载的文件
文件包含漏洞(一)
Mathematical statistics and machine learning
Taskbar explicit / implicit toggle function
Pytorch Chinese document
c语言中的几个关键字
php继承(extends)
Zzuli:1069 learn from classmate Z
1037 Magic Coupon