const ViewPersons = { data () { return { edit: { id: 0, }, form: false, list: [], } }, created () { self = this; self.refresh() }, watch: { '$route': 'refresh' }, methods: { refresh () { getJSON(`//${location.host}${location.pathname}api/person`).then(function(data){ self.list = data; }) }, openAdd() { self.form = true; self.edit.id = 0; }, send() { if (self.edit.id === 0) { httpJSON(`//${location.host}${location.pathname}api/person`,'POST', '"' + self.edit.name + '"') .then(function(data) { self.refresh(); self.form = false; }, function (err) { alert("unable to add new person:" + err.message); }) } } }, template: `

Person

Name
{{ item.name }}
`, }