Ember.js 此.get-in控制器为';不是一个函数';

Ember.js 此.get-in控制器为';不是一个函数';,ember.js,Ember.js,我试图设置html元素的样式,我读到我必须这样做: bid: { popUpContainerDisplay: "none", popUpDisplay: Ember.computed('bid.popUpContainerDisplay', function() { return Ember.String.htmlSafe("display: " + this.get('bid.popUpContainerDisplay')); }) }, 然后在我的hbs文件中,我写

我试图设置html元素的样式,我读到我必须这样做:

bid: {
  popUpContainerDisplay: "none",
  popUpDisplay: Ember.computed('bid.popUpContainerDisplay', function() {
    return Ember.String.htmlSafe("display: " + this.get('bid.popUpContainerDisplay'));
  })
},
然后在我的hbs文件中,我写

<div id="popUpContainer" style={{bid.popUpDisplay}}>

但是,这给了我一些错误:

jQuery.Deferred exception: this.get is not a function TypeError: this.get is not a function
at Object.<anonymous> (http://localhost:4200/assets/auction-ember.js:53:77)
at ComputedPropertyPrototype.get (http://localhost:4200/assets/vendor.js:26852:28)
at Object.get (http://localhost:4200/assets/vendor.js:31759:19)
at NestedPropertyReference.compute (http://localhost:4200/assets/vendor.js:24910:28)
at NestedPropertyReference.value (http://localhost:4200/assets/vendor.js:24720:45)
at ReferenceCache.initialize (http://localhost:4200/assets/vendor.js:55111:52)
at ReferenceCache.peek (http://localhost:4200/assets/vendor.js:55085:29)
at DynamicAttribute.flush (http://localhost:4200/assets/vendor.js:58752:35)
at SimpleElementOperations.addAttribute (http://localhost:4200/assets/vendor.js:58414:36)
at SimpleElementOperations.addDynamicAttribute (http://localhost:4200/assets/vendor.js:58374:22) undefinedjQuery.Deferred.exceptionHook @ jquery.js:3846process @ jquery.js:3642

jquery.js:3855Uncaught TypeError: this.get is not a function(…)
jQuery.Deferred异常:this.get不是函数类型错误:this.get不是函数
反对。(http://localhost:4200/assets/auction-余烬js:53:77)
在ComputedPropertyPrototype.get(http://localhost:4200/assets/vendor.js:26852:28)
at Object.get(http://localhost:4200/assets/vendor.js:31759:19)
在NestedPropertyReference.compute(http://localhost:4200/assets/vendor.js:24910:28)
在NestedPropertyReference.value处(http://localhost:4200/assets/vendor.js:24720:45)
在ReferenceCache.initialize(http://localhost:4200/assets/vendor.js:55111:52)
在ReferenceCache.peek(http://localhost:4200/assets/vendor.js:55085:29)
在达尼卡普特(http://localhost:4200/assets/vendor.js:58752:35)
在SimpleElementOperations.addAttribute中(http://localhost:4200/assets/vendor.js:58414:36)
在SimpleElementOperations.addDynamicAttribute(http://localhost:4200/assets/vendor.js:58374:22)undefinedjQuery.Deferred.exceptionHook@jquery.js:3846process@jquery.js:3642
jquery.js:3855uncaughttypeerror:this.get不是函数(…)

我做错了什么?谢谢。

您尝试使用的对象中不存在
get
方法

get
方法来自类所使用的。您需要做的是使用extend或create将
bid
属性声明为Ember.Object,如下所示:

bid: Ember.Object.extend({
    popUpContainerDisplay: "none",
    popUpDisplay: Ember.computed('bid.popUpContainerDisplay', function() {
       return Ember.String.htmlSafe("display: " + this.get('bid.popUpContainerDisplay'));
    })
})

您需要将计算出的属性从
出价中取出

bid: {
    popUpContainerDisplay: "none"
},
popUpDisplay: Ember.computed('bid.popUpContainerDisplay', function() {
    return Ember.String.htmlSafe("display: " + this.get('bid.popUpContainerDisplay'));
})

我在一个服务中遇到了这个问题,它已经有了
Ember.service.extend()