当前位置:网站首页>在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"
},
边栏推荐
- Software testing - concept
- [paper translation] gcnet: non local networks meet squeeze exception networks and beyond
- Some descriptions of Mipi protocol of LCD
- PHP gets CPU usage, hard disk usage, and memory usage
- ESP8266与STC8H8K单片机联动——天气时钟
- Taskbar explicit / implicit toggle function
- Common websites for Postgraduates in data mining
- Stick to the big screen UI, finereport development diary
- 3D 打印机 G 代码命令:完整列表和教程
- PHP inner class name is the same as the inner class method name
猜你喜欢

Opencv LBP features

【论文翻译】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond

Appnuim environment configuration and basic knowledge

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

Oled12864 LCD screen
![[personal test] copy and paste code between VirtualBox virtual machine and local](/img/ce/eaf0bd9eff6551d450964da72e0b63.jpg)
[personal test] copy and paste code between VirtualBox virtual machine and local

Matplotlib double Y axis + adjust legend position

Lantern Festival gift - plant vs zombie game (realized by Matlab)

【論文翻譯】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond

数理统计与机器学习
随机推荐
Thunder on the ground! Another domestic 5g chip comes out: surpass Huawei and lead the world in performance?
Spark概述
[golang syntax] be careful with the copy of slices
php读文件(读取json文件,转换为数组)
GRBL 软件:简单解释的基础知识
【LeetCode】Day92-盛最多水的容器
mock-用mockjs模拟后台返回数据
492.构造矩形
“簡單”的無限魔方
文件包含漏洞(一)
Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
Technologists talk about open source: This is not just using love to generate electricity
Grbl software: basic knowledge of simple explanation
2022-2-14 learning xiangniuke project - section 23, section 5, development login and exit functions
I want to understand the swift code before I learn it. I understand it
A collection of commonly used plug-ins for idea development tools
1037 Magic Coupon
【論文翻譯】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
STC8H8K系列汇编和C51实战——串口发送菜单界面选择不同功能
PHP inner class name is the same as the inner class method name