Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 财产';提交';不存在_Typescript_Vue.js_Vuex - Fatal编程技术网

Typescript 财产';提交';不存在

Typescript 财产';提交';不存在,typescript,vue.js,vuex,Typescript,Vue.js,Vuex,当我在JavaScript中使用Vuex时,它工作得很好,但在我想将其更改为TypeScript后,它告诉我Vuex中不存在属性“commit”: const突变={ methodA():无{ this.commit('methodB')//在此处引发错误{ if(!bar['title'])控制台。错误('bar需要标题') bar['time']=bar['time']?新日期(bar['time']):新日期() 条['OK']=条['OK']?条['OK']:false 条['foldi

当我在JavaScript中使用Vuex时,它工作得很好,但在我想将其更改为TypeScript后,它告诉我Vuex中不存在
属性“commit”:

const突变={
methodA():无{
this.commit('methodB')//在此处引发错误{
if(!bar['title'])控制台。错误('bar需要标题')
bar['time']=bar['time']?新日期(bar['time']):新日期()
条['OK']=条['OK']?条['OK']:false
条['folding']=条['folding']?条['folding']:false
条形图['child']=普通条形图(条形图['child'])
回程杆
}
var normalbar=(条:任意[]):条[]=>{
var结果=[]
如果(条){
对于(变量i=0;i{
变量结果:any={child:bar}
对于(变量i=0;i{
如果(错误){
此。更新(状态{
条形图:普通条形图([
{title:'1.单击我的文本设置我的状态(OK/Todo)},
{title:['2.要设置新的待办事项吗?请在下面的编辑器中编辑,然后按',
“`Ctrl+Enter`].join(“”)},
{title:['3.一个无用的待办事项栏?向我走去,你可以找到一个垃圾桶',
'图标,然后单击我的删除站图标'].join('')}
])
})
返回
}
state.bar=normalBars(JSON.parse(data.toString()))
})
//编辑初始化
// ------------------------------------------------------------------------
state.editor.container=document.createElement('div')
state.editor.container.style.height='5em'
state.editor.obj=monaco.editor.create(state.editor.container{
值:“”,
语言:“降价”,
对,,
折叠策略:“缩进”,
他说:是的,
概述规则顺序:错误,
scrollBeyondLastLine:false,
小地图:{
已启用:false
}
})
//设置编辑命令以输入消息
state.editor.obj.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter,()=>{
commit('todolist/submit',{message:state.editor.obj.getValue()})
state.editor.obj.setValue(“”)
})
//设置“为根用户输入消息”的命令
state.editor.obj.addCommand(monaco.KeyCode.Escape,()=>{
commit('todolist/addBar',{index:undefined})
})
},
//更新栏并保存
//将state.bar的值设置为'bar',然后将其写入文件路径
更新(状态:状态,{Bar}:{Bar:Bar[];}){
state.bar=条
writeFile(state.filePath,JSON.stringify(state.bar),(err)=>{
如果(错误){
错误(`cannotwrite to${state.filePath}!`)
}
})
},
//按索引杀死条
killBar(state:state,{index}:{index:number[]}){
//重置编辑器的索引
commit('todolist/addBar',{index:undefined})
var index=index.slice()
如果(index.length!=1){
var i=索引u0.pop()
var aim=barByIndex(state.bar,index_u2;)
remote.clipboard.writeText(aim.child[i].title)
目标.子.拼接(i,1)
commit('todolist/update',{bar:state.bar})
}否则{
remote.clipboard.writeText(state.bar[index[0]].title)
状态钢筋接头(索引[0],1)
commit('todolist/update',{bar:state.bar})
}
},
//按索引更改间隔的OK状态
变更状态(状态:状态,{index}:{index:number[]}){
var aim=barByIndex(state.bar,索引)
aim.OK=!aim.OK
commit('todolist/update',{bar:state.bar})
},
//为待办事项列表添加栏:
//-如果索引==未定义,则向根添加条
//-否则,为条添加条[索引[0]][索引[1]]。。。
addBar(state:state,{index}:{index:number[]}){
state.editor.index=索引
if(state.editor.index!=未定义){
var aim=barByIndex(state.bar、state.editor.index)
state.editor.text=editor\u text\u C.sub(aim.title)
}否则{
state.editor.text=editor\u text\u C.main
}
//关注编辑器自动
state.editor.obj.focus()
commit('todolist/update',{bar:state.bar})
},
//待办事项列表的折叠条
折叠栏(状态:状态,{index}:{index:number[];}){
var aim=barByIndex(state.bar,索引)
aim.folding=!aim.folding
commit('todolist/update',{bar:state.bar})
},
//按邮件和索引提交,然后更新:
//-如果索引==未定义,则向根添加条
//-否则,为条添加条[索引]
提交(状态:状态,{message}:{message:string;}){
if(state.editor.index!=未定义){
var aim=barByIndex(state.bar、state.editor.index)
unshift(normalBar({title:message}))
commit('todolist/update',{bar:state.bar})
}否则{
state.bar.unshift(normalBar({title:message}))
commit('todolist/update',{bar:state.bar})
}
}
}
常量getters={
州:(州:州)=>(索引:number[])=>{
var aim=barByIndex(state.bar,索引)
if(aim.child.length!=0){
返回目标。折叠?“折叠”:“展开”
}否则{
返回aim.OK?'OK':'notok'
}
},
折叠:(状态:状态)=>(索引:number[])=>{
返回barByIndex(状态栏、索引)。折叠
},
有子女:(州:州)=>(索引:编号[])=>{
返回barByIndex(state.bar,index).child.length!=0
},
确定:(state:state,getter:any)=>(索引:nu)
const actions = {
  actionOne ({commit}): none {
    commit('methodA')
    commit('methodB')
  },
}