我想使用console.log(this.navParams.get('id')) // prints 10
const id = this.navParams.get('id');
this.categoryRef = this.db.list('/category', ref => ref.orderByChild('id').equalTo(id));
this.category = this.categoryRef.snapshotChanges().map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
});
获取一些数据,但它不起作用,但如果我提供静态值,那么它的工作。我不知道出了什么问题。这是我的代码不起作用并返回空
const id = 10;
this.categoryRef = this.db.list('/category', ref => ref.orderByChild('id').equalTo(id));
this.category = this.categoryRef.snapshotChanges().map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() }));
});
如果我给出静态值,那么它就像
一样var store = new Vuex.Store({
state: {
id: 1,
name: 'aaa',
last: 'bbb'
},
mutations: {
change (state, payload) {
state = Object.assign(state, payload)
}
}
})
new Vue({
el: '#app',
store,
created () {
setTimeout(_ => {
this.$store.commit('change', {
id: 2,
last: 'ccc'
})
}, 2000)
setTimeout(_ => {
this.$store.commit('change', {
name: 'ddd'
})
}, 4000)
}
})
答案 0 :(得分:0)
你能尝试下面的吗?
#include <iostream>
//singly linked list using struct node
void add(struct node *);
struct node {
int data;
struct node *next;
};
int main()
{
struct node *head;
struct node *conductor;
struct node a;
*head = a;
*conductor = a;
add( conductor);
}
void add(struct node *conductor)
{
conductor->next = NULL;
std::cout << "What is the data?\n";
int x;
std::cin>> x ;
if (x == -1) {
return;
} else {
conductor->data = x;
conductor->next = new struct node;
conductor = conductor->next;
add(conductor);
return;
}
}
答案 1 :(得分:0)