zoukankan      html  css  js  c++  java
  • uni-app $refs的基本用法

    $refs的基本用法

    一个对象(Object),持有注册过 ref 特性 的所有 DOM 元素和组件实例。

    <template>
        <view class="container" style="background: #0FAEFF;">
            <view class="child"> hi {{showModal}}</view>
        </view>
    </template>
    <script>
        export default {
            props: {
                showModal: {
                    type: String,
                    default: 'hello'
                }
            },
            data() {
                return {
                    childdata: 'child value'
                };
            },
            methods: {
                sayHello() {
                    console.info("--child:--" + this.showModal);
                }
            }
        }
    </script>
     
    child
    <template>
        <view class="container">
            <child :showModal="showModal" ref="vref"></child>
            
               <button @tap="refMethods" type="primary" >点击</button>
        </view>
    </template>
    
    <script>
        import child from "../../components/child.vue"
    
        export default {
            components: {
                child
            },
            data() {
                return {
                    showModal: " parent say",
                    parentValue: '',
                    syncDate: ' p syncDate'
                };
            },
            methods: {
                refMethods() {
                    var child = this.$refs.vref;
                    child.sayHello();
                }
    
            }
        }
    </script>
    
    <style>
    
    </style>
    parent
  • 相关阅读:
    JDom写入XML例子
    hdu 2549
    hdu 1328
    hdu 1334
    hdu 2547
    hdu 2374
    hdu 2550
    hdu 1335
    hdu 2548
    hdu 1722
  • 原文地址:https://www.cnblogs.com/J-wym/p/10329533.html
Copyright © 2011-2022 走看看