wxc-toast

    title传值

    属性传参设置文案

    1. <wxc-toast
    2. is-show="{{$toast.show}}"
    3. text="Hello World"></wxc-toast>
    4. <button bindtap="showToast">属性传值</button>
    5. </template>
    6. <script>
    7. export default {
    8. config: {
    9. usingComponents: {
    10. 'wxc-toast': '@minui/wxc-toast'
    11. }
    12. },
    13. data: {
    14. $toast: {
    15. show: false
    16. }
    17. },
    18. /** note: 在 wxp 文件或者页面文件中请去掉 methods 包装 */
    19. methods: {
    20. showToast() {
    21. this.setData({
    22. $toast: {
    23. show: true
    24. }
    25. })
    26. setTimeout(() => {
    27. this.setData({
    28. $toast: {
    29. show: false
    30. }
    31. })
    32. }, 1500)
    33. }
    34. }
    35. }
    36. </script>
    37. <style>
    38. </style>

    自定义 icon 色

    设置 icon 颜色 #ff5777

    提示框 toast - 图2

    自定义 icon 图片

    1. <template>
    2. <wxc-toast
    3. src="https://s10.mogucdn.com//mlcdn/c45406/171017_885a650c746k7hajhf04aja566h1i_68x68.png"
    4. text="{{$toast.title}}"></wxc-toast>
    5. <button bindtap="showToast">自定义 icon 图片的 toast</button>
    6. </template>
    7. <script>
    8. export default {
    9. config: {
    10. usingComponents: {
    11. 'wxc-toast': '@minui/wxc-toast'
    12. }
    13. },
    14. data: {
    15. $toast: {
    16. show: false,
    17. title: ""
    18. }
    19. /** note: 在 wxp 文件或者页面文件中请去掉 methods 包装 */
    20. methods: {
    21. showToast() {
    22. this.setData({
    23. $toast: {
    24. show: true,
    25. title: "自定义 icon 图片"
    26. }
    27. });
    28. setTimeout(() => {
    29. this.setData({
    30. $toast: {
    31. show: false,
    32. title: ''
    33. }
    34. })
    35. }, 1500)
    36. }
    37. }
    38. }
    39. </script>
    40. <style>
    41. </style>

    设置 icon

    设置 icon 为 yes

    提示框 toast - 图4

    子元素传值

    1. <template>
    2. <wxc-toast is-show="{{$toast.show}}">Hello World</wxc-toast>
    3. <button bindtap="showToast">子元素传值</button>
    4. </template>
    5. <script>
    6. export default {
    7. config: {
    8. usingComponents: {
    9. 'wxc-toast': '@minui/wxc-toast'
    10. }
    11. },
    12. data: {
    13. $toast: {
    14. show: false
    15. },
    16. /** note: 在 wxp 文件或者页面文件中请去掉 methods 包装 */
    17. methods: {
    18. showToast() {
    19. this.setData({
    20. $toast: {
    21. show: true
    22. }
    23. })
    24. setTimeout(() => {
    25. this.setData({
    26. $toast: {
    27. show: false
    28. }
    29. })
    30. }, 1500)
    31. }
    32. }
    33. }
    34. <style>
    35. </style>

    长文案支持

    长文案提示,文案换行显示

    提示框 toast - 图6

    调用show方法显示

    调用 show(message) 方法显示 toast

    1. <template>
    2. <wxc-toast
    3. class="J_toast"
    4. text="Hello World"></wxc-toast>
    5. <button bindtap="showToast">调用 show() 方法显示</button>
    6. </template>
    7. <script>
    8. export default {
    9. config: {
    10. usingComponents: {
    11. 'wxc-toast': '@minui/wxc-toast'
    12. }
    13. },
    14. data: {},
    15. /** note: 在 wxp 文件或者页面文件中请去掉 methods 包装 */
    16. methods: {
    17. showToast() {
    18. let $toast = this.selectComponent(".J_toast")
    19. $toast && $toast.show('这是show方法传值')
    20. }
    21. }
    22. }
    23. </script>
    24. <style>
    25. </style>

    v1.0.8(2018.03.29)

    • show() 方法增加 message 参数

    v1.0.7(2018.01.16)

    • icon-image 属性更改为 src,1.0.7 及以上版本的 min 支持本地图片路径

    v1.0.6(2018.01.09)

    • z-index 层级规范方案修改

    v1.0.3(2018.01.04)

    • 修复自定义 icon 时,icon 的颜色样式问题,规范 z-index 规范

    v1.0.2(2017.11.02)

    • update .npmignore

    v1.0.1(2017.10.24)

    • 初始版本