{{title}}"> I don't know how to create changeable text for reusable component in Vue Js-PHP Chinese Network Q&A
I don't know how to create changeable text for reusable component in Vue Js
P粉957723124
P粉957723124 2023-09-03 22:33:40
0
1
419

I'm creating a reusable tab component by watching a tutorial. After watching it, I understood how it works. However, for my project I need to create tabs with a title that can be changed since this is a reusable component so I have to change the title for each new tab but I haven't figured it out yet Find out how. I need to somehow get the title from the TabsWrapper component I added to the page

{{title}}

Then let this header change the text inside this div, which is the main header of the TabsWrapper component.

{{title}}

My code: The first is the out-of-component code I added to the homepage of the website.

 Hello 1 Hello 2  Hello 3 Hello 4 

The second one is the code inside the component responsible for TabsWrapper

 

This code gets each title from the Tab

Hello 1

This code renders it

  • {{ title }}
  • I tried repeating the same technique and it worked, but I think there is a better way

     
    {{headtitle}}
    • {{ title }}

    P粉957723124
    P粉957723124

    reply all (1)
    P粉418351692

    You can simply pass the props in the script tag and access them directly using this keyword and the prop name.

    export default { props: ['foo'], created() { // props are exposed on `this` console.log(this.foo) } }

    In a template tag like this

    {{ foo }}

    You don't need to use ref you can just use v-for directly and loop over the array elements.

  • {{item}}
    • Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!