新手来了 我对以下代码有问题。我想定义一个受保护的“仪表板”页面,如下所示,但给了我这个绑定错误:
Binding element 'Component' implicitly has an 'any' type.ts(7031)
import * as React from "react";
import { Route, Router, Redirect } from "react-router-dom";
import Dashboard from "../features/dashboard";
import LoginContainer from "../features/login/containers/LoginContainer";
import SignUpContainer from "../features/signup/containers/SignUpContainer";
import { createBrowserHistory } from "history";
const history = createBrowserHistory();
export default () => (
<Router history={history}>
<Route path="/" component={LoginContainer} />
<Route path="/login" component={LoginContainer} />
<Route path="/register" component={SignUpContainer} />
<PrivateRoute path="/dashboard" component={Dashboard} />
</Router>
);
function PrivateRoute({ component: Component, ...rest }) {
return ( …Run Code Online (Sandbox Code Playgroud) 我想使用来自 youtube 和其他类似平台的 iframe - 但我不知道如何使用变量作为我的源。
我已经搜索过了,但我得到的答案没有奏效。
所以这里是 iframe:
<div class="right">
<h2>Associated Pictures/Media Files</h2>
<p>Here we will display either Infos, Fotos, Videos, Music or even interative content.</p>
<div style="padding: 2%;">
<iframe
width="100%"
height="315"
src="https://www.youtube.com/embed/Q7hmXN714RQ"
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen>
</iframe>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我唯一想要的是在这里使用这个变量:
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
source = 'https://www.youtube.com/embed/Q7hmXN714RQ';
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试以各种方式做到这一点时 - 例如:
src="{{source}}"
Run Code Online (Sandbox Code Playgroud)
这根本不起作用:(
有谁知道如何正确地做到这一点?我找不到针对此问题的适当解决方案。