【问题标题】:Uncaught (in promise) ReferenceError: Unable to process binding "text: function(){return 'selection is: '+val }" Message: val is not definedUncaught (in promise) ReferenceError: Unable to process binding "text: function(){return 'selection is: '+val }" Message: val is not defined
【发布时间】:2019-05-24 12:40:12
【问题描述】:

VM11347:3 Uncaught (in promise) ReferenceError: Unable to process binding "text: function(){return 'selection is: '+val }" 消息:val 没有定义

employee.js

define(['ojs/ojcore','knockout'],
function(oj,ko)
{  
  function AboutViewModel()
  {
      var self=this;
      self.val= ko.observable('nothing selected');
       document.getElementById('globalBody').addEventListener('selectionUpdate',selectionHandler,false);

       function selectionHandler(event)
       {
            self.val(event.detail.data);

       }

  }
});


employee.html

<div class="oj-hybrid-padding"> 
<h1>Employee Content</h1>
<div>
    <oj-bind-text value="[['selection is: '+val]]"></oj-bind-text>
    <h2> <input data-bind="value:val"></input></h2>
</div>
</div>

【问题讨论】:

    标签: oracle-jet


    【解决方案1】:

    您已定义 AboutViewModel,但尚未从您的定义块返回任何内容。在 AboutViewModel 函数结束后添加:

    return new AboutViewModel();
    

    【讨论】:

      【解决方案2】:
      employee.js
      
      
         function selectionHandler(event)
         {
              self.val('selection is: '+event.detail.data);
      
         }
      

      employee.html

      <oj-bind-text value="[[$data.val]]"></oj-bind-text>
      <h2> <input data-bind="value:val"></input></h2>
      

      嗨,

      您不能在同一个 jet 中同时进行硬编码和返回值。为此,您可以在 js 本身中设置值时定义它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-12-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多