连接字符串&带点符号的变量=错误

Concatenating String & Variable With Dot Notation = Error?

本文关键字:符号 变量 错误 字符串 amp 连接      更新时间:2023-09-26

我正在丑化一些Angular,并在连接字符串和变量的块中出错。。。对于MongoDB,我需要使用点符号引用数组索引。。。

['images.exterior.' + index]: content,

错误消息为:警告:取消确认失败。意外的令牌:字符串(images.externation.).

对我来说,这是一个奇怪的问题,我甚至不知道从哪里开始寻找?有人能推荐另一种将字符串和变量连接为键的方法吗?

[更新1]

尝试连接并使用与"images.externation.0"相同的变量:内容,

但它用Mongoose:发送了一个空请求

Mongoose:inventos.findAndModify({})[]{'$setOnInsert':{__v:0}}{new:true,upsert:true,remove:false}

变量未被字符串值替换。。。如果我使用一个编码字符串"images.externation.0",它就可以了。。。。。。。

谢谢John

结束连接使其通过Uglify,并且仍然可以使用Mongoose。

var holder = {};
holder["images.interior."+ index] = content;

然后变成了。。。

inventory.update({id:$scope.item._id}, {
    $set: holder
}).$promise.then(function(data){
    $scope.item.images.interior = data.images.interior;
});