我正在尝试将此列表添加到我的视图模型中,以使一些绑定更简单一些。但是,为了做到这一点,我无法弄清楚语法。
var images = [
{ name: "Image 1", photo: "/images/image1.jpg" },
{ name: "Image 2", photo: "/images/image2.jpg" },
{ name: "Image 3", photo: "/images/image3.jpg" },
];
var viewModel = {
favorite: "",
...
}
答案 0 :(得分:1)
将图像分配到viewModel
,如下所示:
var viewModel = {
favorite: "",
images: images
};
然后像viewModel.images