领先的免费Web技术教程,涵盖HTML到ASP.NET

网站首页 > 知识剖析 正文

uniapp经验-总结1

nixiaole 2024-11-22 18:51:23 知识剖析 18 ℃

打包h5

  • 1、设置mainfest.json中h5节点的publicPath为:'./'
  • 2、打包完毕后找到index.xxxxx.js文件,将uniConfig.router={mode:"hash",base:"/"}修改为uniConfig.router={mode:"hash",base:"./"}

请求延迟


 "networkTimeout" : {
        "uploadFile" : 100000000,
        "request" : 100000000
    },

大项目打包h5

       "h5" : {
        "title" : "微领",
		    "domain" : "",
		    "router" : {
		        "mode" : "hash",
		        "base" : "./"
		    },
		    "publicPath" : "./",
		    "optimization" : {
		        "treeShaking" : {
		            "enable" : true
		        }
		    },
		    "uniStatistics" : {
		        "enable" : false
		    },
		    "sdkConfigs" : {
		        "maps" : {}
		    }
        }

app跳转到网页

 // #ifdef APP-PLUS
var url ="www.baidu.com"
plus.runtime.openURL( url );
 // #endif

h5跳转到网页

// #ifdef H5 
window.location.href=that.urls
// #endif

colorUI动画

style有animationDelay:0.1s//动画延时
clss有animation-reverse//动画逆行

animation-动画名
fade//淡入
scale-up//变大进入
scale-down//变小进入
slide-top//上入
slide-bottom//下入
slide-left//左入
slide-right//右入
shake//颤抖

打开app的方法

if (plus.os.name == 'Android') {
		//判断是app
		plus.runtime.launchApplication(
		{
pname: 'com.ss.android.ugc.aweme'	//软件包名,用跳转网页方法也可以打开app
		},
		function(e) {
			console.log('Open system default browser failed: ' + e.message);
		}
		);
	
}else if (plus.os.name == 'iOS') {
	//判断是ios
	plus.runtime.launchApplication(
	{ 
		action:'snssdk1128://aweme'		//网页地址
	}, function(e) {
		console.log('Open system default browser failed: ' + e.message);
	});
	
	}

富文本方法

<rich-text :nodes="nodes"></rich-text>	
data() {
return {
image:""
}
},
computed:{
nodes(){
let node = this.image;
node =  node.replace(/\<img/g, '<img style="width: 100%"');
// console.log(node)
return node;
	}
},

公共样式

<Return></Return>
import Return from "../components/return.vue"
components:{
	Return
	},

过滤器

<view>买家姓名:{{lists.name|nulls}}</view>
filters:{
nulls(data){
	if(data==undefined){ return ""}
}
}

顶部状态框高度

calc(var(--status-bar-height)
height: var(--status-bar-height);	
padding-top: calc(var(--status-bar-height) + 30rpx);

plus.runtime.versionCode //版本号不带点
plus.runtime.version //版本号带点
min-height: 100vh;//自适应高

Tags:

最近发表
标签列表