进一步/递归对象解构

时间:2018-04-18 21:57:53

标签: javascript node.js

我有这个:

const {ops} = getOplogStreamInterpreter(strm);

ops.del.subscribe(v => {
  console.log('delete happened 1.');
});

ops.insert.subscribe(v => {
  console.log('insert happened 1.');
});

ops.update.subscribe(v => {
  console.log('update happened 1.');
});

只是想知道是否有可能这样做:

const {{insert,del,update}} = getOplogStreamInterpreter(strm);

基本上进一步构造返回的对象。

1 个答案:

答案 0 :(得分:3)

我认为你可以这样做:

<script src="https://unpkg.com/vue"></script>

<div id="app">
  <form v-on:submit.prevent="saveData">
    <input type="text" name="test">
    <button type="submit">Go</button>
  </form>
  <hr>
  <form v-on:submit="saveData">
    <input type="text" name="test">
    <button type="submit">I WONT PREVENT</button>
  </form>
</div>

<script type="text/javascript">
  new Vue({
    'el': '#app',
    'methods': {
      'saveData': function(event) {
        console.log('I was called');
      }
    }
  });
</script>