vue mining pit

1.ref

ref is required when accessing child component instances in parent components, or directly manipulating DOM elements

<input ref="ipt">

Get this input via this.$refs.ipt

$refs are non-responsive and should not be data bound in templates

2. Custom events

$on  $emit

<!--Use v-on to monitor in html-->
<my-component v-on:test="callbackFun"></my-component>
<script>
//Directly use $on to monitor
vm.$on( 'text',function(){})
</script>

3. Skip css detection

For elements that only use js too much, use v-bind:css = "false" to skip vue's detection of css

4. Custom Components

The name of the custom component cannot use html keywords or candidate words, otherwise it will be parsed as an html element

5. The child component calls the method defined by the parent component through the button

Parent component:

<p @childBtn = "ServiseList"></p>

methods:{

 ServiseList () {

  router.push({

    name:'search',

    params:this.ListParameter

  })

  } 

}

Subassembly:

<button type="button" @click="commonality"></button>

methods:{

  commonality(){

    this.$emit("childBtn ")

  }

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324612218&siteId=291194637