F-loat / mpvue-quickstart

🐱‍👤 更优雅的 mpvue 起手式
http://mpvue.com/mpvue/quickstart
172 stars 34 forks source link

请问一下vant-weapp类似notify如何使用,非组件 #22

Closed zhangzilong1992 closed 5 years ago

zhangzilong1992 commented 5 years ago

请问一下vant-weapp类似notify如何使用,非组件

F-loat commented 5 years ago
<template>
  <van-notify id="van-notify" />
</template>

<script>
import Notify from 'vant-weapp/dist/notify/notify'

export default {
  config: {
    usingComponents: {
      'van-notify': '/static/vant-weapp/dist/notify/index'
    }
  },
  mounted() {
    Notify('通知内容')
  }
}
</script>
F-loat commented 5 years ago

0.1.3 版的 mpvue-config-loader 搭配相应的 webpack 配置修改 https://github.com/F-loat/mpvue-quickstart/commit/b828586223a6ac9bf5d735c898808f7f5b4b89da ,可实现以下写法

<template>
  <van-notify id="van-notify" />
</template>

<script>
import Notify from 'vant-weapp/dist/notify/notify'

export default {
  config: {
    usingComponents: {
      'van-notify': 'vant-weapp/dist/notify/index'
    }
  },
  mounted() {
    Notify('通知内容')
  }
}
</script>