我正在尝试找到一种方法来使用我制作的模型组件,但能够从其中一个插槽关闭模型。
我可以将数据传递到插槽,但不能使用 v-model,并且不相信我可以更改插槽属性来关闭模型打开状态
https://v3.vuejs.org/guide/component-slots.html#scoped-slots
这是我正在使用的弹出窗口
<PopoverModal>
<template #toggleButton>
<button>A</button>
</template>
<template #modalContent="{ toggleModal }">
<div style="color: #fff; height: 400px; width: 400px;">test2 {{toggleModal}}</div>
<button @click="toggleModal = false">click me</button>
</template>
</PopoverModal>
Run Code Online (Sandbox Code Playgroud)
在弹出窗口组件中,我试图发送状态变量
<slot name="modalContent" :toggleModal="showSelector"></slot>
Run Code Online (Sandbox Code Playgroud)
我猜答案是不可能的,并找到另一种方法,但如果有人知道那就太好了,谢谢
我来自 vue,习惯了可组合函数。我正在尝试找出以 svelte 方式做到这一点的方法
因此,我创建了一个 js 文件并导入存储,然后尝试创建一个可以在多个组件上调用并单独操作的函数
swipe.js 文件
import { writable, derived, get } from 'svelte/store';
function createSwipe() {
const dyFromStart = writable(0)
function moveEvent(eventType, val){
console.log('moveEvent', eventType, val, get(dyFromStart))
dyFromStart.update(n => n + 1);
}
const dxScore = derived(dyFromStart, $dyFromStart => $dyFromStart + 3)
const dyScore = derived(dyFromStart, $dyFromStart => Math.round($dyFromStart + 100));
return {
moveEvent,
dxScore,
dyScore,
};
}
export const swipe = createSwipe();
Run Code Online (Sandbox Code Playgroud)
然后在 .svelte 组件中导入脚本中的函数并分解为子部分
import { writable, derived, get } from 'svelte/store';
function createSwipe() …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用vuetify@2.0.0-alpha.17,而不是使用vue时自动以其开始的1.5.13添加vuetify。然后我尝试这篇文章Update Vuetify版本方法。我做
vue create my-app
cd my-app
vue add Vuetify
npm uninstall -S vuetify
npm install -S vuetify@2.0.0-alpha.17
Run Code Online (Sandbox Code Playgroud)
并得到错误
This dependency was not found:
* vuetify/src/stylus/app.styl in ./src/plugins/vuetify.js
To install it, you can run: npm install --save vuetify/src/stylus/app.styl
Run Code Online (Sandbox Code Playgroud)
哦,好的,就是这样安装它。不,这也只会带来错误。就像我只想开始使用2.0.0一样,以便他们发布它(希望很快)时,我不必重新构建所有内容。不知道为什么这么难,就像在文档中告诉我们该怎么做,不是每个人都是向导,而谷歌搜索问题不起作用