感谢提供图片的网站 https://blog.csdn.net/qq_36120342/article/details/87437581
// 判断一个url是否可以访问
function IsLoad(url, fun) {
$.ajax({
url: url,
type: 'Post',
success: function(response) {
if ($.isFunction(fun)) {
fun(true);
}
},
error: function() {
if ($.isFunction(fun)) {
fun(false);
}
}
});
}
import IsLoad from "../../common/checkImg"
IsLoad(that.attr, function(res) {
if (!res) {
that.attr = '../../static/me/USER@2x.png'
}
// alert('请求的url可以访问');
})
检查视频的地址
<view class="" v-if="urlVideo!=''">
<video :src="urlVideo" controls autoplay="true"></video>
</view>
<script>
import checkMPUrl from '../../../common/checkmp4.js'
onload:方法
if (that.content.indexOf('video') !== -1) {
if (that.content.indexOf('.mp4') !== -1)
this.urlVideo = that.content.substring(that.content.indexOf('src') + 5, that.content.indexOf('mp4') + 3)
// this.urlVideo ='http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'
console.log("视频地址:", urlVideo)
if (checkMPUrl(this.urlVideo) != 200) {
uni.showToast({
title: "该视屏无法播放",
icon: 'none'
})
}
} else {
this.urlVideo = "";
}
style:
.video {
height: 200px;
flex: 1;
}
function CheckStatus(url){
$.ajax({
type: "GET",
cache: false,
url: url,
dataType: "jsonp", //跨域采用jsonp方式
processData: false,
data: "",
complete: function (data) {
if (data.status==200) {
console.log("成功");
} else {
console.log("失败");
}
}
});
}