我在 react 中遇到错误,无法在组件中嵌套组件。我在 Header 组件和 Search 组件中都收到错误消息。对于 Header 组件,我收到上述错误:
类型{孩子:元素;与 IntrinsicAttributes 类型没有共同的属性
我试图在组件中嵌套组件,如下所示:
<Header>
<Grid>
<Cell span={3} />
<Cell span={6}>
<Search handleUpdateQueryParam={this.handleUpdateQueryParam} />
</Cell>
<Cell span={3}>
<Avatar image="https://pbs.twimg.com/profile_images/624249118114881536/qxn_I_oR_400x400.jpg" />
</Cell>
</Grid>
</Header>
Run Code Online (Sandbox Code Playgroud)
我的 Header 是一个无状态组件,如下所示:
interface HeaderProps {
children: any;
}
export const Header: React.FC<HeaderProps> = ({ children }) => {
return <div className="mll-header">{children}</div>;
};
Run Code Online (Sandbox Code Playgroud)
我不知道为什么不幸出现此错误。如果有人可以帮助我,那真是太棒了!
抱歉,我是 node.js 的新手,想知道是否允许我们在 ejs 文件中使用 vue.js。
我知道这是一个非常具体的问题,但想知道是否有人可以帮助我。所以现在我正在使用位于此链接上的引导程序中的模块:
https://bootstrap-vue.js.org/docs/components/pagination/
我目前在尝试调度依赖于 currentPage 变量的操作时遇到麻烦。
<bPagination align="right" :total-rows="100" v-model="currentPage" :per-page="10" @click.native =" updatePage(currentPage); loadParticipants()"></bPagination>
Run Code Online (Sandbox Code Playgroud)
目前 currentPage 设置为 1,如下所示:
data() {
return {
currentPage: 1,
tag: '',
tags: [],
....
Run Code Online (Sandbox Code Playgroud)
这是一种方法,可以让我更新 VueX 商店中的页面。首先,我在 Vue 文件中调度一个方法:
updatePage: function(page){ this.$store.dispatch('updatePage', page); console.log("Hit me") },
Run Code Online (Sandbox Code Playgroud)
然后在我的 VueX 商店中我使用这个函数来提交:
updatePage({ commit }, updatePage) { commit('updatePage', updatePage); }
Run Code Online (Sandbox Code Playgroud)
然后我使用突变来最终更新状态数据:
updatePage: (state, updatePage) => { state.page = updatePage; }
Run Code Online (Sandbox Code Playgroud)
所以我想要它做的是,每次我点击页码时,当您按下任何页码时,我都会立即更新 vuex 存储中的页码。但是,每次我单击页码时,它都会减少和增加一步。
例子:
如果我点击第 2 页两次,它会将商店数据更新到第 2 页
如果您单击第 2 页,然后单击第 1 页,则会显示商店的页码位于第 2 页。
所以它几乎落后了一步。如果有人能把我推向正确的方向,那会有很大帮助。谢谢!
所以这里的目标是将所有0移动到数组的末尾,但我偶然发现了这些小行代码中的问题.
当我使用输入时,我得到所需的输出,如下所示:
Input: [0,1,0,3,12]
Output: [1,3,12,0,0]
Run Code Online (Sandbox Code Playgroud)
但是,每当我使用此输入时:
[0,0,1]
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
[0,1,0]
Run Code Online (Sandbox Code Playgroud)
当我想要输出时:
[1,0,0]
Run Code Online (Sandbox Code Playgroud)
我不知道为什么我认为我正确实现了这个:
class Solution:
def moveZeroes(self, nums):
"""
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
"""
for counter in range(len(nums)):
if nums[counter] == 0:
nums.pop(counter) #Remove the 0
nums.append(0) #Add to end.
counter-=1 #Check same index just incase adjacent 0
Run Code Online (Sandbox Code Playgroud)
任何输入都表示赞赏.谢谢!
我希望能够遍历一个集合,以便能够遍历所有对象。这是我的架构:
'use strict';
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const bcrypt = require('bcrypt');
const moment = require('moment');
//Create user schema
const UserSchema = new Schema ({
username: { type: String, unique:true },
password: {type:String},
phonenumber: Number,
});
//**************PASSWORD STUFF *******************************
//Hash the password so it becomes encrypted.
UserSchema.methods.generateHash = function(password){
return bcrypt.hashSync(password,bcrypt.genSaltSync(9));
}
UserSchema.methods.validPassword = function(password){
return bcrypt.compareSync(password,this.password);
}
//************************************************************
//Schema model.
const User = mongoose.model('user-dodger', UserSchema);
module.exports = User;
Run Code Online (Sandbox Code Playgroud)