Polymer 1.0:如何嵌套函数?

Polymer 1.0: How to nest functions?

我想调用一个观察者函数 '_propChanged',该函数又会调用另外两个函数 _foo()_bar()。我该怎么做?

代码

{
  is: 'x-el',
  properties: {
    prop: {
      type: String,
      notify: true,
      observer: '_propChanged'
    }
  },
  _propChanged: function() {
    _foo(); // This doesn't work
    _bar(); // This doesn't work
  },
  _foo: function() {
    // Do stuff
  },
  _bar: function() {
    // Do stuff
  }
}

只需在函数调用前加上 this 前缀即可正确解析名称。

_observePropChanges: function () {
  this._foo();
  this._bar();
}