native-button-container.uvue 661 B

1234567891011121314151617181920212223242526272829303132333435
  1. <template>
  2. <view>
  3. <button type="primary" @tap="testCallMethod">调用组件方法</button>
  4. <native-button id="helloView1" class="native-button" text="自定义组件"></native-button>
  5. </view>
  6. </template>
  7. <script>
  8. import { createNativeButtonContext } from "@/uni_modules/native-button";
  9. export default {
  10. data() {
  11. return {
  12. title: '组件能力封装示例',
  13. }
  14. },
  15. methods: {
  16. ontap(e : UniNativeViewEvent) {
  17. console.log("ontap----------" + e.type)
  18. },
  19. testCallMethod: function () {
  20. let context = createNativeButtonContext("helloView1", this)
  21. context?.updateText("test code")
  22. }
  23. }
  24. }
  25. </script>
  26. <style>
  27. </style>