gpt4 book ai didi

javascript - Breezejs EntityType.createEntity 未使用可观察值包装属性

转载 作者:行者123 更新时间:2023-12-02 17:04:46 25 4
gpt4 key购买 nike

breeze 默认情况下应该用 observable 和 observableArrays 包装属性,对吗?为什么在这种情况下不这样做?

var apiService = new breeze.DataService({
serviceName: 'api',
hasServerMetadata: false
});

var store = new breeze.MetadataStore({
namingConvention: breeze.NamingConvention.camelCase
});

var movieType = new breeze.EntityType({
shortName: 'Movie',
dataProperties: [
new breeze.DataProperty({
name: "id",
dataType: breeze.DataType.ID,
isNullable: false,
isPartOfKey: true
}),
new breeze.DataProperty({
name: "title",
dataType: breeze.DataType.String,
isNullable: false
})
]
});

store.addEntityType(movieType);

function Movie() {
var self = this;

self.isBeingEdited = false;
}

store.registerEntityTypeCtor('Movie', Movie);

var manager = new breeze.EntityManager({
dataService: apiService,
metadataStore: store
});

var favoriteMovie = movieType.createEntity({
id: 123,
title: "5th Element",
stars: ['Bruce Willis', 'Milla Yovovich']
});

manager.addEntity(favoriteMovie);

alert(favoriteMovie.title()); //errors favoriteMovie.title is not a function

最佳答案

上面的代码没问题。问题是我在 knockout.js 之前包含了 breeze.js 包含的顺序很重要。

关于javascript - Breezejs EntityType.createEntity 未使用可观察值包装属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25350947/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com