当前位置:网站首页>在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"
},
边栏推荐
- STC8H8K系列匯編和C51實戰——數碼管顯示ADC、按鍵串口回複按鍵號與ADC數值
- STC8H8K系列汇编和C51实战——串口发送菜单界面选择不同功能
- Win10 copy files, save files... All need administrator permission, solution
- File contains vulnerability (I)
- Web页面用户分步操作引导插件driver.js
- 15 C language advanced dynamic memory management
- Mathematical statistics and machine learning
- mysql事务和隔离级别
- LCD之MIPI协议的一些说明
- RGB 无限立方体(高级版)
猜你喜欢
软件测试 - 概念篇
all3dp. All Arduino projects in com website (2022.7.1)
《CGNF: CONDITIONAL GRAPH NEURAL FIELDS》阅读笔记
Cambrian was reduced by Paleozoic venture capital and Zhike shengxun: a total of more than 700million cash
Pytorch Basics
Minimum value ruler method for the length of continuous subsequences whose sum is not less than s
Gcnet: non - local Networks meet Squeeze excitation Networks and Beyond
Technologists talk about open source: This is not just using love to generate electricity
Test case
【論文翻譯】GCNet: Non-local Networks Meet Squeeze-Excitation Networks and Beyond
随机推荐
File contains vulnerabilities (II)
深度学习分类网络--VGGNet
软件测试 - 概念篇
Web页面用户分步操作引导插件driver.js
[golang syntax] be careful with the copy of slices
c语言中的几个关键字
PHP inner class name is the same as the inner class method name
Several keywords in C language
PHP gets CPU usage, hard disk usage, and memory usage
STC8H8K系列汇编和C51实战——数码管显示ADC、按键串口回复按键号与ADC数值
PHP obtains some values in the string according to the specified characters, and reorganizes the remaining strings into a new array
深度学习分类网络 -- AlexNet
Technologists talk about open source: This is not just using love to generate electricity
vite如何兼容低版本浏览器
1035 Password
DRM display framework as I understand it
Uva548 tree
Win10 copy files, save files... All need administrator permission, solution
文件包含漏洞(二)
Software testing - concept