我正在使用 MAT Dialog,我试图将带有对话框表单数据的变量值传递给函数,我得到了表单值,但没有变量值。见附图:
通过按下按钮,我做了两件事,将任务 ID 的值分配给变量并打开对话框:
addSubtask(task){
this.taskID = task._id;
const dialogSubTaskRef = this.dialog.open(AddNewSubtaskDialog, {
data{
taskID: this.taskID,
description: this.subtaskDescription,
dueDate: this.subtaskDuedate,
}
});
dialogSubTaskRef.afterClosed().subscribe(data => {
console.log("Subtask Dialog output:", data);
}
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在尝试通过taskID对话框,但当我登录控制台data时它不会显示。data
如何将此变量值与对话框表单值一起传递给我的函数?
感谢您的帮助!
我创建了一个测试文件来测试我的以下“BiddingScreen”,
const BiddingScreen = ({ route, navigation }) => {
const { currentBid } = route.params;
return (
<SafeAreaView style={styles.main}>
<Header title="BID Here" navigation={navigation} />
<View style={styles.container}>
<Text style={styles.currentBid}>{CurrentBid}$</Text>
</View>
</SafeAreaView>
)}
Run Code Online (Sandbox Code Playgroud)
我的测试文件如下,
import React from 'react';
import renderer from 'react-test-renderer';
import BiddingScreen from "../../../src/containers/biddingScreen/BiddingScreen";
jest.mock('@react-native-firebase/auth');
jest.mock("react-native/Libraries/EventEmitter/NativeEventEmitter");
test('renders correctly', () => {
const tree = renderer.create(< BiddingScreen />).toJSON();
expect(tree).toMatchSnapshot();
});
Run Code Online (Sandbox Code Playgroud)
当我运行测试文件时出现此错误,
TypeError: Cannot read property 'params' of undefined
Run Code Online (Sandbox Code Playgroud)
那么谁能帮我解决这个问题,谢谢
typescript jestjs react-native babel-jest react-test-renderer
我已经在我的 Angular 应用程序中成功安装了 primeng !样式工作正常,但按钮点击上的波纹动画不起作用!
在我的应用程序组件中 -
import { PrimeNGConfig } from 'primeng/api';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent implements OnInit {
constructor(private primengConfig: PrimeNGConfig) {}
ngOnInit() {
this.primengConfig.ripple = true;
}
}
Run Code Online (Sandbox Code Playgroud)
我还在我的应用程序模块中导入了 BrowserAnimationsModule!但它仍然不起作用!如果我遗漏了什么,请告诉我!
我想在LinkReact-Router-Dom的组件内的事件对象上触发停止传播方法。我的问题是,当我单击Link元素内的按钮时,它无论如何都会将我移动到另一个页面。我看到 stopPropagation 方法工作不正常,Link元素上的 onClick 事件正在触发。如何防止这种行为?
我已经在 codeSandbox 上准备了一个示例,但在这个示例中,Link并没有将我移动到另一个页面,而只是刷新页面。
示例 https://codesandbox.io/s/serene-surf-h65dz?file=/src/Home.js
我的代码:
const handleClick = e => {
e.stopPropagation();
return console.log("Works?");
};
return (
<Link to={`/edytuj/${item.ID}`} className="table__row">
<Checkbox
isSelected={isSelected}
toggleSelection={() => handleSelection(item, isSelected)}
></Checkbox>
<TableRowItem>{item.ID}</TableRowItem>
<TableRowItem
src={item.IMAGE}
additionalClassName="table__image"
></TableRowItem>
<TableRowItem>{item.NAME}</TableRowItem>
<TableRowItem>{item.DESCRIPTION}</TableRowItem>
<TableRowItem additionalClassName="table__cost">
{item.COST} z?
</TableRowItem>
<TableRowItem additionalClassName="table__buttons">
<Button className="btn btn__edit" icon="fas fa-pen btn__icon">
Edytuj
</Button>
<Button
onClick={e => handleClick(e)}
className="btn btn__delete"
icon="fas fa-times btn__icon"
>
Usu?
</Button>
</TableRowItem>
</Link>
);
Run Code Online (Sandbox Code Playgroud)
按钮:
const …Run Code Online (Sandbox Code Playgroud) 我想为我的 Badge 组件传递数据道具,但库中的array方法有问题addon-knobs。Data prop 是一个对象数组,我试图像这样传递它:
const data = [
object('First', {color: '#fa2dac', text: 'RSS'}),
object('Second', {color: '#fa2dac', text: 'RSS'}),
];
Run Code Online (Sandbox Code Playgroud)
这给我的结果是我有 2 个字段(第一个和第二个),但是当我想更改内部的值时,它们不会在屏幕上更新。
第二次尝试:
const data = array('List of items', [
object('First', {color: '#fa2dac', text: 'RSS'}),
object('Second', {color: '#fa2dac', text: 'RSS'}),
]);
Run Code Online (Sandbox Code Playgroud)
这给了我相同的结果,但我得到了 3 个字段而不是 2 个字段,而第三个字段具有价值 [object Object]
第三次尝试:
const data = array('List of items', [
{color: '#fa2dac', text: 'RSS'},
{color: '#fa2dac', text: 'RSS'},
]);
Run Code Online (Sandbox Code Playgroud)
这给我只提交了 [object Object]
如何添加带有对象数组的旋钮并进行全面更新?
我正在使用bootstrap4创建轮播,并且图像来自数组。我的问题是第一个元素必须具有类active。
<div id="carouselExampleFade" class="carousel slide carousel-fade" data-ride="carousel">
<div class="carousel-inner">
<div class="carousel-item" *ngFor="let image of sliderImages" [ngClass]="image[0] ? 'active' : null">
<img class="d-block w-100" [src]="image" alt="First slide">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleFade" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleFade" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
Run Code Online (Sandbox Code Playgroud) 我想创建一个动态函数,该函数从字符串返回一个变量。我正在使用ES6中的模板字符串,但我不知道以后如何调用。我需要传递一个保留对象作为参考的变量。
const checkDeviceWidth = type => {
if (documentWidth > 1200) return `${type}Options`;
if (documentWidth > 414) return `${type}MediumOptions`;
return `${type}MobileOptions`;
};
...
<Lottie
ref={backgroundImg}
isClickToPauseDisabled={true}
speed={1}
options={checkDeviceWidth('background')}></Lottie>
Run Code Online (Sandbox Code Playgroud)
返回对象取决于参数
const backgroundOptions = {
loop: true,
autoplay: true,
animationData: background.default,
};
const backgroundMediumOptions = {
loop: true,
autoplay: true,
animationData: backgroundMedium.default,
};
Run Code Online (Sandbox Code Playgroud)
有了这个,我得到一个错误,在选项中我必须传递一个对象而不是一个字符串。没有eval()功能以后如何调用呢?我正在与React合作
我是 nuxt 和 vue 的新手,我正在尝试将颜色主题从深色更改为浅色。我的项目是由 nuxt cli 生成的,我有这个版本:
"dependencies": {
"core-js": "^3.8.3",
"nuxt": "^2.14.12",
"vuetify": "^2.4.4"
}
"devDependencies": {
"@nuxtjs/vuetify": "^1.11.3"
}
Run Code Online (Sandbox Code Playgroud)
我正在通过此链接学习如何执行此操作:https://vuetifyjs.com/en/features/theme/
但实际上,当我尝试更改某些颜色或主题时,什么也没有发生。我试图通过光明或黑暗的道具,但仍然没有发生
<v-app dark>...</v-app>
Run Code Online (Sandbox Code Playgroud)
插件/vuetify.js
import Vue from "vue";
import Vuetify from "vuetify/lib";
Vue.use(Vuetify);
export default new Vuetify({
theme: {
themes: {
light: {
primary: "#00bcd4",
secondary: "#8bc34a",
accent: "#3f51b5",
error: "#e91e63",
warning: "#ffeb3b",
info: "#2196f3",
success: "#4caf50"
}
}
}
});
Run Code Online (Sandbox Code Playgroud) javascript ×4
reactjs ×3
typescript ×3
angular ×2
babel-jest ×1
bootstrap-4 ×1
dialog ×1
html5 ×1
jestjs ×1
nuxt.js ×1
primeng ×1
react-native ×1
react-router ×1
storybook ×1
vue.js ×1
vuejs2 ×1
vuetify.js ×1