鍍金池/ 問答/Linux  HTML/ 為什么vux報錯,this.$vux.confirm.prompt is not

為什么vux報錯,this.$vux.confirm.prompt is not a function?

錯誤:

圖片描述

代碼:

<template>
<div class="g-inherit m-main p-general" v-if="myInfo.account">

<group class="u-card">
  <cell :title="myInfo.nick" :inline-desc="'帳號: ' + myInfo.account">
    <img class="icon" slot="icon" width="20" :src="myInfo.avatar">
  </cell>
</group>
<group class="u-card">
  <cell title="昵稱">{{myInfo.nick || ''}}</cell>
  <cell title="性別">{{myInfo.gender}}</cell>
  <cell title="生日">{{myInfo.birth}}</cell>
  <cell title="手機(jī)">{{myInfo.tel}}</cell>
  <cell title="郵箱">{{myInfo.email}}</cell>
  <cell title="簽名">{{myInfo.sign}}</cell>
</group>
<div>
  <x-button type="warn" action-type="button" @click.native="logout">注銷</x-button>
</div>
<div v-transfer-dom>
  <confirm v-model="show"
  title="confirm title"
  @on-cancel="onCancel"
  @on-confirm="onConfirm"
  @on-show="onShow"
  @on-hide="onHide">
    <p style="text-align:center;">{{ 'Are you sure?' }}</p>
  </confirm>
</div>
<br>
<div style="padding:15px;">
  <x-button @click.native="showPlugin" type="primary">{{ 'show' }}</x-button>
</div>

</div>
</template>

<script>
import Vue from 'vue'
import { Group, Cell, Confirm, TransferDomDirective as TransferDom } from 'vux'
export default {
directives: {

TransferDom

},
components: {

Group,
Cell,
Confirm

},
data () {

return {
  show : false
}

},
computed: {

myInfo () {
  return this.$store.state.myInfo
}

},
methods: {

logout () {
  let that = this
  this.$vux.confirm.show({
    title: '確定要注銷帳號?',
    onConfirm () {
      that.$store.dispatch('logout')
    }
  })
},
onCancel(){
  console.log('on cancel')
},
onConfirm(msg){
    console.log('on confirm')
    if(msg){
      alert(msg)
    }
},
onHide(){
  console.log('on hide')
},
onShow(){
  console.log('on show')
},
showPlugin () {
  const _this = this
  this.$vux.confirm.prompt('123', {
    title: 'Title',
    onShow () {
      console.log('promt show')
      _this.$vux.confirm.setInputValue('set input value')
    },
    onHide () {
      console.log('prompt hide')
    },
    onCancel () {
      console.log('prompt cancel')
    },
    onConfirm (msg) {
      alert(msg)
    }
  })
}

}
}
</script>

回答
編輯回答
賤人曾

confirm的其他方法都能生效就prompt不生效嗎?

你可以向vue注冊這個組件

import  { ConfirmPlugin } from 'vux'
Vue.use(ConfirmPlugin)
2018年4月19日 12:29