使用变量字符串设置插槽的简单方法? [英] Easy way to set a slot with a string of a variable?
本文介绍了使用变量字符串设置插槽的简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有很多 slot
示例,但没有我需要的简洁和简单......我需要类似的东西
There are many slot
examples but no clair and simple as I need... I need something like
var x="Hello";
$slot = x;
这就是我需要的...
在一个具体的例子中:https://jsfiddle.net/2qdh3x3v/
我需要一个简单的方法在单击ShowModal1"时将插槽header
设置为HELLO",并设置为BYE!"单击ShowModal2"时.
In a concrete example: https://jsfiddle.net/2qdh3x3v/
I need a easy way to set slot header
to "HELLO" when click "ShowModal1", and to "BYE!" when click "ShowModal2".
推荐答案
您可以创建一个变量并通过单击所需的按钮来更改它:
You can create a variable and change it by clicking on the desired button:
<button id="show-modal" @click="(header = 'HELLO') && (showModal = true)">
Show Modal1
</button>
<button id="show-modal" @click="(header = 'BYE!') && (showModal = true)">
Show Modal2
</button>
...
<h3 slot="header">{{header}}</h3>
https://jsfiddle.net/6k9drL1t/1/
这篇关于使用变量字符串设置插槽的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文