更新记录
1.1.0(2023-04-21)
本次主要更新: 1.andorid 修复 list里设置原生组件圆角,高度不全的情况
1.0.1(2022-10-17)
新版首发
平台兼容性
Android | Android CPU类型 | iOS |
---|---|---|
适用版本区间:5.0 - 12.0 | armeabi-v7a:支持,arm64-v8a:支持,x86:支持 | 适用版本区间:9 - 16 |
原生插件通用使用流程:
- 购买插件,选择该插件绑定的项目。
- 在HBuilderX里找到项目,在manifest的app原生插件配置中勾选模块,如需要填写参数则参考插件作者的文档添加。
- 根据插件作者的提供的文档开发代码,在代码中引用插件,调用插件功能。
- 打包自定义基座,选择插件,得到自定义基座,然后运行时选择自定义基座,进行log输出测试。
- 开发完毕后正式云打包
付费原生插件目前不支持离线打包。
Android 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/android
iOS 离线打包原生插件另见文档 https://nativesupport.dcloud.net.cn/NativePlugin/offline_package/ios
注意事项:使用HBuilderX2.7.14以下版本,如果同一插件且同一appid下购买并绑定了多个包名,提交云打包界面提示包名绑定不一致时,需要在HBuilderX项目中manifest.json->“App原生插件配置”->”云端插件“列表中删除该插件重新选择
KJ-CoverView
原生组件设置圆角、支持video、map、webview等等
使用
<template>
<view class="content">
<KJ-CoverView class="coverView" ref="coverView">
<web-view class="webView" src="https://www.dcloud.io/"></web-view>
</KJ-CoverView>
<KJ-CoverView class="coverView" ref="coverView2">
<map class="map"></map>
</KJ-CoverView>
<KJ-CoverView class="coverView" ref="coverView3">
<video class="video"
src="https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/a876efc0-4f35-11eb-97b7-0dc4655d6e68.mp4"></video>
</KJ-CoverView>
<button type="primary" @click="setStyle1">设置圆角</button>
<button type="primary" @click="setStyle2">恢复为直角</button>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello'
}
},
onLoad() {
},
onReady() {
setTimeout((res) => {
this.setStyle1();
}, 100)
},
methods: {
setStyle(cornerRadius) {
this.$refs.coverView.getSubviewClassNames((res) => { //获取所有子view的类名
console.log("getSubviewClassNames:" + JSON.stringify(res))
var indexs
if (plus.os.name == 'Android') {
var index = this.getIndex(res.result,
"io.dcloud.feature.weex.adapter.webview.DCWXWebView$1")
indexs = [index];
} else {
var index = this.getIndex(res.result, "WKScrollView")
indexs = [index];
}
/**
* indexs - 根据getSubviewClassNames返回类名字,判断是否设置圆角,传数组索引
* cornerRadius - andorid版圆角角度,最大为高度的一半,超过之后,设置无效
* */
this.$refs.coverView.setStyle({
"indexs": indexs,
"cornerRadius": cornerRadius
}, (res) => {
console.log("setStyle:" + JSON.stringify(res))
})
})
this.$refs.coverView2.getSubviewClassNames((res) => {
console.log("getSubviewClassNames2:" + JSON.stringify(res))
var indexs
if (plus.os.name == 'Android') {
var index = this.getIndex(res.result, "io.dcloud.feature.weex_amap.ui.MapLayout")
var index2 = this.getIndex(res.result, "io.dcloud.feature.weex_amap.adapter.WXMapView")
indexs = [index, index2];
} else {
var index = this.getIndex(res.result, "MAMapView")
indexs = [index];
}
this.$refs.coverView2.setStyle({
"indexs": indexs,
"cornerRadius": cornerRadius
}, (res) => {
console.log("setStyle2:" + JSON.stringify(res))
})
})
this.$refs.coverView3.getSubviewClassNames((res) => {
console.log("getSubviewClassNames3:" + JSON.stringify(res))
var indexs
if (plus.os.name == 'Android') {
var index = this.getIndex(res.result, "io.dcloud.feature.weex_media.VideoPlayerView")
indexs = [index];
} else {
var index = this.getIndex(res.result, "WXH5VideoPlayView")
indexs = [index];
}
this.$refs.coverView3.setStyle({
"indexs": indexs,
"cornerRadius": cornerRadius
}, (res) => {
console.log("setStyle3:" + JSON.stringify(res))
})
})
},
setStyle1() {
this.setStyle("100")
},
setStyle2() {
this.setStyle("0")
},
getIndex(list, className) {
for (let i = 0; i < list.length; i++) {
var str = list[i];
if (className == str) {
return i;
}
}
}
}
}
</script>
<style>
.webView,
.map,
.video {
width: 750rpx;
height: 200px;
}
</style>
<template>
<view class="content">
<button type="primary" @click="setStyle1">设置圆角</button>
<button type="primary" @click="setStyle2">恢复为直角</button>
<list @scroll="">
<cell v-for="(item, index) in 30" :key="index">
<KJ-CoverView class="coverView" :ref="'coverView'+index">
<video class="video"
src="https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/a876efc0-4f35-11eb-97b7-0dc4655d6e68.mp4"></video>
</KJ-CoverView>
</cell>
</list>
</view>
</template>
<script>
export default {
data() {
return {
title: 'Hello',
height: '500px'
}
},
onLoad() {
},
onReady() {
setTimeout((res) => {
this.setStyle1();
}, 100)
},
methods: {
(res) {
this.setStyle1();
},
setStyle(cornerRadius) {
for (var i = 0; i < 30; i++) {
let ins = this.$refs[`coverView${i}`][0]
ins.getSubviewClassNames((res) => {
console.log("getSubviewClassNames3:" + JSON.stringify(res))
var indexs
if (plus.os.name == 'Android') {
var index = this.getIndex(res.result, "io.dcloud.feature.weex_media.VideoPlayerView")
indexs = [index];
} else {
var index = this.getIndex(res.result, "WXH5VideoPlayView")
indexs = [index];
}
ins.setStyle({
"indexs": indexs,
"cornerRadius": cornerRadius
}, (res) => {
console.log("setStyle3:" + JSON.stringify(res))
})
})
}
},
setStyle1() {
this.setStyle("100")
},
setStyle2() {
this.setStyle("0")
},
getIndex(list, className) {
for (let i = 0; i < list.length; i++) {
var str = list[i];
if (className == str) {
return i;
}
}
}
}
}
</script>
<style>
.webView,
.map,
.video {
width: 400rpx;
height: 500px;
}
</style>