如何更改v-alert内部文本/ html?

时间:2018-09-26 14:09:13

标签: vue.js vuetify.js

我使用vuetifyvue-property-decorator来显示警报:

<v-alert dismissible :value="true" color="error" icon="new_releases">
  some text.. some text.. <a @click="changeTheAlertMessage">click me</a>.
</v-alert>

如何通过单击a按钮更改内部文本/ html?

@Component({})
export default class SomeView extends Vue {
  changeTheAlertMessage() {
    //here: How I access to alert instance???
  }
}

1 个答案:

答案 0 :(得分:0)

在这里您可以找到working example

使用的方法如下:

  1. 将要更改的文本建模为反应数据变量;
  2. 定义一个名为changeTheAlertMessage()的方法,该方法旨在根据您的需要更改文本。

我的意思是这样:

new Vue({
  el: '#app',
  data () {
    return {
      messageToChange: "Original text"
    }
  },

  methods: {
    changeTheAlertMessage: function(event) {
     this.messageToChange = "New text"
    }
  }
})