未捕获(承诺中)ReferenceError:无法处理绑定“文本:function(){返回'选择为:'+ val}”消息:未定义val

时间:2019-05-24 12:40:12

标签: oracle-jet

  

VM11347:3未捕获(承诺)ReferenceError:无法处理   绑定“文本:function(){返回'选择是:'+ 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>

2 个答案:

答案 0 :(得分:0)

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

return new AboutViewModel();

答案 1 :(得分:0)

function Datatable() {

  // ... bunch of code

  // do you need state for this?
  const [removeStudent, setremoveStudent] = useState([]);

  // ... more code

  const getEntries = async () => {

    // ... 

    setremoveStudent(deleteData); // not sure this is needed...
  };

employee.html

ctrl+j

嗨,

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