【发布时间】:2020-08-12 03:36:06
【问题描述】:
我有一个 Angular 8 应用程序。我尝试嵌入 vimeo 视频。
所以我有这样的ts:
getVideoId(url, prefixes) {
const cleaned = url.replace(/^(https?:)?\/\/(www\.)?/, '');
for (let i = 0; i < prefixes.length; i++) {
if (cleaned.indexOf(prefixes[i]) === 0) {
return cleaned.substr(prefixes[i].length);
}
}
return undefined;
}
getVimeoId(url) {
return this.getVideoId(url, ['vimeo.com/', 'player.vimeo.com/']);
}
getVideoSafeUrl(url: string): SafeResourceUrl {
const embedUrl = this.parseYoutubeUrl(url);
const safeUrl = this.domSanitizer.bypassSecurityTrustResourceUrl(
this.parseVimeo(embedUrl));
return safeUrl;
}
和这样的模板:
<iframe
*ngIf="videoUrl.value"
class="video-iframe"
type="text/html"
[src]="getVideoSafeUrl(videoUrl.value)"
frameborder="0"
allowfullscreen
></iframe>
但是当我尝试插入 vimeo 视频时:https://vimeo.com/346340496/11432ab1db
我收到此错误:
VM7131 vendor.js:76269 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: '346340496'
Error: Cannot match any routes. URL Segment: '346340496'
at ApplyRedirects.push../node_modules/@angular/router/fesm5/router.js.ApplyRedirects.noMatchError (router.js:2432)
at CatchSubscriber.selector (router.js:2413)
at
那么我要改变什么?
谢谢
【问题讨论】:
标签: javascript angular typescript embed vimeo