Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div id="App1">
    <input type="text" v-model="inputTodo">
    <button v-on:click="Add">Add</button>
    <hr>
    <ol>
      <li v-for="(item,idx) in todos">
        <input type="checkbox" v-model="item.finish">
        <input type="text" v-bind:disabled="item.finish" v-model="item.txt">
        <button v-if="item.finish" v-on:click="Del(idx)">X</button>
      </li>
    </ol>
    <hr>
    {{todos}}
  </div>
  
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</body>
</html>
 
let App1=new Vue({
  el:'#App1',
  data:{
    inputTodo:'',
    todos:[
      {txt:'JavaScript',finish:false},
      {txt:'Vue',finish:true},
      {txt:'All',finish:false},
    ],
  },
  methods:{
    Add:function(){
      let tmpTodo={};
      tmpTodo.txt=this.inputTodo;
      this.todos.push(tmpTodo);
      this.inputTodo='';
    },
    Del:function(idx){
      console.log(idx);
      this.todos.splice(idx,1);
    }
  }
  
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
topcattwpro
0viewers