最近在插件市场看到一个视频解析的插件,挺感兴趣的,发现要99块钱,就自己研究了一下webview,发现实现起来也不难,我的实现思路是注入js文件拿到视频地址调用解析接口,实现播放,下面贴上代码,有兴趣的小伙伴可以研究下.
<template>
<view>
<web-view :src="src" @message="handleMessage"></web-view>
</view>
</template>
<script>
export default {
data() {
return {
src:''
}
},
// 标题栏input搜索框点击
onNavigationBarSearchInputClicked: async function(e) {
var pages = getCurrentPages();
var page = pages[pages.length - 1];
var currentWebview = page.$getAppWebview();
currentWebview.children()[0].getURL();
const nw = currentWebview.children()[0];
// var nw=plus.webview.create('http://m.weibo.cn/u/3196963860',{top:'46px',bottom:'0px'});
},
//点击导航栏 buttons 时触发
onNavigationBarButtonTap(e) {
uni.navigateTo({
url: '../index/index'
});
},
onReady() {
var pages = getCurrentPages();
var page = pages[pages.length - 1];
var currentWebview = page.$getAppWebview();
currentWebview.children()[0].getURL();
const nw = currentWebview.children()[0];
nw.appendJsFile('hybrid/html/js/uni.webview.1.5.1.js');
nw.appendJsFile('hybrid/html/js/jquery.min.js');
nw.appendJsFile('h