vue中使用layui彈框layui-layer

1.在vue中引入layui-layer

npm i --save layui-layer

2.引入jquery

 <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>

3,使用

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>

  </div>
</template>

<script>
import layer from 'layui-layer'
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },
  created: function () {
    layer.confirm('您是如何看待前端開發?', {
      btn: ['重要', '奇葩'] // 按鈕
    }, function () {
      layer.msg('的確很重要', {icon: 1})
    }, function () {
      layer.msg('也可以這樣', {
        time: 20000, // 20s後自動關閉
        btn: ['明白了', '知道了']
      })
    })
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>

4.運行

npm start
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章