typescript
1import Vue from 'vue'; 2import axios from 'axios'; 3import jquery from 'jquery'; 4 5import * as Models from '../../system/typescript-angularjs-client-generated/model/models'; 6import * as ViewModel from './VM'; 7 8/// <reference path="../typings/index.d.ts" /> 9 10/// <reference path="../typings/globals/jquery/index.d.ts" /> 11 12Vue.use(VueObserveVisibility) 13 14export class Main_Contents { 15 16 private ViewModel: ViewModel.VM 17 18 private version: string 19 private hash: string 20 21 constructor(versionStr: string, hash: string) { 22 23 this.ViewModel = new ViewModel.VM() 24 25 let params = new URLSearchParams() 26 params.append("version", versionStr) 27 params.append("hash", hash) 28 axios.post('', params) 29 .then(response => { 30 if (response.data.status == 0) { 31 this.getData() 32 } 33 }) 34 } 35 36 getData(): void { 37 38 let ViewModel = this.ViewModel 39 40 let vue = new Vue({ 41 el: "#all_contents", 42 data: ViewModel, 43 mounted: { 44 45 }, 46 methods: { 47 48 } 49 }); 50 51 /*--view control--*/ 52 53 vue.$watch("flag", function () { 54 vue.$nextTick(function () { 55 vue.data = 1 56 }) 57 }) 58 } 59 } 60}
この形式だと
vue.$watch("flag", function () {
vue.$nextTick(function () {
vue.data = 1
})
})
の部分は正しく動作するのですが
typescript
1vue.$watch("flag", func()) 2 3function func(){ 4 vue.$nextTick(function () { 5 vue.data = 1 6 }) 7}
このような書き方をすると
Argument of type '"flag"' is not assignable to parameter of type '(this: CombinedVueInstance<Vue
と、flagの方にエラーが出てしまします...(>__<)
functionを分けたいんですがどのようにすればいいでしょうか...
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/03/14 04:40
2018/03/16 08:12
退会済みユーザー
2018/03/16 08:41
退会済みユーザー
2018/03/16 08:41
退会済みユーザー
2018/03/19 05:43