js/r

var myApp = new Framework7();
var $$ = Dom7;

var mainView = myApp.addView(‘.view-main’, {
 dynamicNavbar: true,
 animateNavBackIcon: true,
 scrollTopOnStatusbarClick: true,
});

var STORAGE_KEY = ‘f7-vue-todo’;
var todoStorage = {
 load: function () {
 var todos = JSON.parse(localStorage.getItem(STORAGE_KEY) || ‘[]’)
 return todos
 },
 save: function (todos) {
 localStorage.setItem(STORAGE_KEY, JSON.stringify(todos))
 }
}

var app = new Vue({
 // element to mount to
 el: ‘#app’,
 // initial data
 data: {
 todos:todoStorage.load(),
 todo: {
 title: ‘’,
 done: false 
 }
 },
 watch: {
 todos: {
 handler: function (todos) {
 //console.log(todos);
 todoStorage.save(todos)
 },
 deep: true
 }
 },

// methods
 methods: {
 addTodoUI: function(event) {
 //myApp.prompt(‘Add todo ‘ , function (value) {
 //console.log(app)
 //if(value){
 //app.addTodo(value);
 //}
 //});
 
 this.addTodo(Date.now());
 },
 addTodo: function (value) {
 
 this.todos.push({“id”: Date.now(),”title”: value, “done”: false }); 
 },
 deleteTodo: function (todo) {
 //myApp.alert(todo.id);
 //this.todos.splice(this.todos.indexOf(todo), 1)
 console.log(todo);
 this.todos.splice(todo, 1);
 //this.todos.splice
 }
 }
})

Show your support

Clapping shows how much you appreciated Orçun’s story.