因为我正在尝试将youtube视频动态嵌入我的Angular 2应用程序中,所以正在努力解决一些安全错误.在这里找到关于使用管道来清理网址的答案.
但遇到此当前错误.
无法找到管道'safeResourceUrl'
import { Pipe } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
@Pipe({name: 'safeResourceUrl'})
export class SafeResourceUrl {
constructor(private sanitizer:DomSanitizer){}
transform(url) {
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
}
Run Code Online (Sandbox Code Playgroud)
import { NgModule } from '@angular/core';
import { HomeModule } from './home/home.module';
import { SharedModule } from './shared/shared.module';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { SafeResourceUrl } from './shared/pipes/saferesourceurl.pipe';
@NgModule({
declarations: [
AppComponent,
SafeResourceUrl
],
imports: [
SharedModule,
HomeModule,
AppRoutingModule
] …
Run Code Online (Sandbox Code Playgroud) 我在我的React应用程序中使用Redux,目前只有1个减速器用于加密货币组合.只是一堆硬币.
当我第一次收到一个预期的1个对象的数组时,我调度我的ADD_COIN动作.然而,当我再次在另一个硬币上调用dispatch时,它再次返回Array,但仍然只有1个项目,即所选的最新硬币.
如何重新编写这些以使用所有添加的硬币返回更新的数组?
const store = createStore(reducer, compose(
applyMiddleware(thunk),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
));
Run Code Online (Sandbox Code Playgroud)
import { combineReducers } from 'redux'
import portfolio from './portfolio'
export default combineReducers({
portfolio
});
Run Code Online (Sandbox Code Playgroud)
import * as R from 'ramda'
import * as api from '../../services/api'
import { addToPortfolio, getPortfolio } from '../../services/coinFactory'
export const ADD_COIN = 'ADD_COIN'
export function addCoin(coin) {
return dispatch =>
api.getCoin(coin)
.then((res) => addToPortfolio(R.head(res.data)))
.then((portfolio) => dispatch(add(portfolio)));
}
//action creator
export function add(portfolio) {
return { …
Run Code Online (Sandbox Code Playgroud) npmv3.10.10
节点v6.11.0
eslintv4.2.0
你可以在这里拉回购。就在npm install
这时npm run lint
我正在尝试使用以下导出语句(评论有效,但很难看):
export MainContainer from './Main/MainContainer'
// export { default as MainContainer } from './Main/MainContainer'
Run Code Online (Sandbox Code Playgroud)
import React from 'react'
import { Route, HashRouter, browserHistory } from 'react-router-dom'
import { MainContainer } from '../containers'
const routes = (
<HashRouter history={browserHistory}>
<Route path="/" component={MainContainer} />
</HashRouter>
)
export default routes
Run Code Online (Sandbox Code Playgroud)
我安装了以下软件包:
npm install babel-eslint@next --save-dev
{
parser: "babel-eslint",
en: {
es6: true,
browser: …
Run Code Online (Sandbox Code Playgroud) 尝试将此变量重命名assetPayoutType
为 just payType
,但是因为我在使用 TypeScript,所以出现了问题。TypeScript 认为有一种类型叫做payType
.
const { title, assetPayoutType } = this.props;
mapDailyAssets(assetPayoutType: string)
Run Code Online (Sandbox Code Playgroud)
IE:这行不通:
mapDailyAssets(assetPayoutType: payType: string)
Run Code Online (Sandbox Code Playgroud)
我在 StackOverflow 上搜索,找到了两个没有回答这个问题的答案。
答案描述了非打字稿/常规 Javascript 简单重命名:
这个答案是关于 VSCode 重构的:
在我的 NextJS/React 打字稿应用程序中,我使用了 setTimeout。
React 应用程序中存在一个错误,导致 setTimeout 立即被调用,然后我在此答案中找到了修复程序:ReactJS:setTimeout() 不起作用?
下面是我的代码,但我发现在以下打字稿错误this
的this.resetNotification
任何“this”隐式具有类型“any”,因为它没有类型注释。ts(2683) Board.tsx(158, 7):“this”的外部值被此容器遮蔽。
@bind
resetNotification(): any {
console.log('resetNotification...');
this.setState({ notificationClass: 'spin-in-notification' });
this.props.setNotification('', false);
}
@bind
private handleNotificationClick() {
this.setState({ notificationClass: 'slide-out-bck-top' });
setTimeout(
function() {
this.resetNotification();
}
.bind(this),
500
);
}
Run Code Online (Sandbox Code Playgroud)
我正在使用now.sh来部署我的nextjs (React) 应用程序。由于此错误,构建失败:
Build error occurred
ReferenceError: describe is not defined
不知道为什么这开始发生,这是我的 .babelrc
{
"env": {
"development": {
"compact": false,
"presets": [
"next/babel",
"@zeit/next-typescript/babel"
],
"plugins": [
["styled-components", {"ssr": true, "displayName": true}],
["@babel/plugin-proposal-decorators", {"legacy": true}]
]
},
"production": {
"presets": [
"next/babel",
"@zeit/next-typescript/babel"
],
"plugins": [
["styled-components", {"ssr": true, "displayName": true}],
["@babel/plugin-proposal-decorators", {"legacy": true}]
]
},
"test": {
"compact": false,
"presets": [
"@babel/preset-typescript",
["next/babel", {"preset-env": { "modules": "commonjs" }}]
],
"plugins": [
["styled-components", { "ssr": true, "displayName": …
Run Code Online (Sandbox Code Playgroud) 嗨,我希望找到正确的语法,以便更好地组织Flash AS3中的Case语句.所以下面例如不是有3个案例陈述,我不能以某种方式组织成1个案例吗?
switch (refID)
{
case "TS_38":
pgBool = true;
break;
case "TS_37":
pgBool = true;
break;
case "TS_36":
pgBool = true;
break;
default:
pgBool = false;
//break;
}
Run Code Online (Sandbox Code Playgroud)
我尝试了这个,但它在我的测试中没有用:
switch (refID)
{
case "TS_38", "TS_37", "TS_36":
pgBool = true;
break;
default:
pgBool = false;
//break;
}
Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的javascript函数来返回所选字段的索引,它看起来像这样:
function validateForm() {
alert(document.getElementByID('textfieldAmount').selectedIndex);
return false;
}
Run Code Online (Sandbox Code Playgroud)
这是从onClick上的输入按钮调用的,如下所示:
onclick="return validateForm();"
Run Code Online (Sandbox Code Playgroud)
但是从不调用Javascript,无论如何都会提交页面.
如果我将警报更改为警报("wibble"); 警报工作正常,页面未提交.
我查询的元素看起来像这样:
<select name="textfieldAmount" id="textfieldAmount" class="form">
Run Code Online (Sandbox Code Playgroud)
有什么想法为什么它在我杀了自己之前没有工作?
嗨,我正在尝试使用jQuery为背景图像设置动画,我尝试在这里使用本教程,但是我的测试页面没有运气,我看到了蓝色的Facebook图标,但鼠标悬停在它上面并没有动画向上显示灰色的标志.请帮忙!谢谢,我是一个jQuery noob.
我的测试页面: http ://leongaban.com/_stack/bg_animation/
Facebook图标应向上动画,完整图片如下:
我的CSS
<style>
#facebook_icon li {
padding: 0;
width: 120px;
height: 119px;
list-style: none;
background: red;
background:url('img/fb_120x238.png') repeat 0 0;
}
</style>
Run Code Online (Sandbox Code Playgroud)
HTML
<ul id="facebook_icon">
<li><a href="#"><div class="box"></div></a></li>
</ul>
Run Code Online (Sandbox Code Playgroud)
使用Javascript
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.bgpos.js"></script>
<script>
(function() {
$('#facebook_icon li')
.css( {backgroundPosition: "0 0"} )
.mouseover(function(){
$(this).stop().animate(
{backgroundPosition:"(0 -119px)"},
{duration:500})
})
.mouseout(function(){
$(this).stop().animate(
{backgroundPosition:"(0 0)"},
{duration:500})
})
})();
</script>
Run Code Online (Sandbox Code Playgroud)
更新:工作CSS 3解决方案
CSS 3
#facebook_icon li {
padding: 0;
width: 120px; …
Run Code Online (Sandbox Code Playgroud) 我还在想着如何重新说出这个标题.
无论如何,所以我在这个页面上有这个联系表格:http://leongaban.com/
当您单击名称并填写它时,您可以选择标记到下一个字段电子邮件.输入电子邮件后,用户很自然地再次进入消息框.
但是由于某种原因,我的标签选择一直跳到页面顶部,似乎选择了我的投资组合主导航链接.还有一些标签,我回到了短信textarea.
这当然不是理想的,有没有办法可以强制选项卡选择按正确顺序排列?即:名称>电子邮件>消息>验证码>提交
我目前的表格(HTML)
<div class="the-form">
<form id="myForm" action="#" method="post">
<div>
<label for="name">Your Name</label>
<input type="text" name="name" id="name" value="" tabindex="1">
</div>
<div>
<label for="email">Your Email</label>
<input type="text" name="email" id="email" value="" tabindex="1">
</div>
<div>
<label for="textarea">Message:</label>
</div>
<div>
<textarea cols="40" rows="8" name="message" id="message"></textarea>
</div>
<p><em>Hi, what is 2 + 3?</em></p>
<input type="text" name="captcha" id="captcha" />
<div>
<input class="submit-button" type="submit" value="Submit">
</div>
</form>
</div>
</footer>
Run Code Online (Sandbox Code Playgroud) javascript ×8
reactjs ×4
typescript ×3
html ×2
next.js ×2
angular ×1
bitcoin ×1
case ×1
css ×1
eslint ×1
flash ×1
forms ×1
jestjs ×1
jquery ×1
lint ×1
react-redux ×1
redux ×1
renaming ×1
settimeout ×1
tab-ordering ×1
variables ×1