Vue uses scope slots to work and cannot display components

when using scoped components, I follow the tutorial to do an example, but I can"t display the components and the content passed. I don"t know why? The
code is as follows:

               <div id="G14">
                

<n-component slot-scope="props">

{{ props.text }}

</n-component> </div> <script> Vue.component("n-component",{ template:"<div><slot text=""></slot></div>" }) new Vue({ el:"-sharpG14" }) </script>

looks like

in the browser

clipboard.png

The

console did not report an error either. What is the problem?

Feb.26,2021

there may be some problems with the slot of your subcomponents, but regardless of that, slot-scope can be written in two ways.

  1. write without template

    <n-component>
      

    // slot <p slot-scope="props">{{ props.text }}

    </n-component>
  2. use template

    <n-component>
      <template slot-scope="props">
        <p >

    {{props.text}}

    </template> </n-component>
What does

mean? this slot-scope is added to the structure corresponding to slot.

Menu