Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在v2中使用slot-scope可以获取到值 在v3使用#default获取不到值 #61

Open
aYangyunpeng opened this issue Jun 22, 2022 · 15 comments

Comments

@aYangyunpeng
Copy link

No description provided.

@shanlh
Copy link
Owner

shanlh commented Jun 22, 2022

<template #default="{ data }">
这样试试

@aYangyunpeng aYangyunpeng changed the title 在v2中使用slot-scope可以获取到值 在v3使用#defalut获取不到值 在v2中使用slot-scope可以获取到值 在v3使用#default获取不到值 Jun 22, 2022
@aYangyunpeng
Copy link
Author

<template #default="{ data }"> 这样试试

我在您的评论的issues里 下载了^3.0.0-alpha.2 这个版本

@aYangyunpeng
Copy link
Author

import * as Tinder from "vue-tinder";
目前是不支持在vite + v3这样引入吗
我也参考了您的例子 也在过往的问答中发现了这个我已经复现的问题
无法找到模块“vue-tinder”的声明文件。
尝试使用 npm i --save-dev @types/vue-tinder (如果存在),或者添加一个包含 declare module 'vue-tinder'; 的新声明(.d.ts)文件

@shanlh
Copy link
Owner

shanlh commented Jun 22, 2022

可能因为我这不是 ts 的原因😂

@aYangyunpeng
Copy link
Author

其实我也没有使用ts 正常引入也会提示这个问题

@aYangyunpeng
Copy link
Author

`

<script setup> import { defineComponent, ref, getCurrentInstance } from "vue"; import * as Tinder from "vue-tinder"; import source from "../bind"; defineComponent({ components: { Tinder, }, }); const queue = ref([]); const offset = ref(0); const history = ref([]); const mock = (count = 5, append = true) => { const list = []; for (let i = 0; i < count; i++) { list.push({ id: source[offset.value] }); offset.value++; } if (append) { queue.value = queue.value.concat(list); } else { queue.value.unshift(...list); } }; const onSubmit = ({ item }) => { if (queue.value.length < 3) { mock(); } history.value.push(item); }; mock(); </script>` 我这是按照您的例子写v3 一个简单的demo 但是没办法正常展现效果

@shanlh
Copy link
Owner

shanlh commented Jun 22, 2022

方便的话在 https://codesandbox.io/ 上复现下

@aYangyunpeng
Copy link
Author

@shanlh
Copy link
Owner

shanlh commented Jun 23, 2022

感觉这 setup 表现不正常,用普通的 <script> 是可以的

@aYangyunpeng
Copy link
Author

不使用v3的语法糖 引入是正常了 但是设置样式又消失了

@aYangyunpeng
Copy link
Author

https://codesandbox.io/s/smoosh-sun-evdv0j?file=/src/App.vue 如果您有空的话 请帮忙看一下沙盒代码

@shanlh
Copy link
Owner

shanlh commented Jun 23, 2022

V3 你还要引入样式:
import 'vue-tinder/lib/style.css'
Vite 打包还不支持把这样式整进去😂

@booladsudan
Copy link

Hello I have the same problem, if you can make it work with composition api please help.

@shanlh
Copy link
Owner

shanlh commented Jul 25, 2022

Hello I have the same problem, if you can make it work with composition api please help.

It's support Composition API,But not "<script setup>",
<script setup> is a compile-time syntactic sugar for using Composition API inside Single-File Components (SFCs).
So you can use as usual: <script>...</script>, with your composition api code.
And don't forget import style file: import 'vue-tinder/lib/style.css'

@booladsudan
Copy link

Hello I have the same problem, if you can make it work with composition api please help.

It's support Composition API,But not "<script setup>", <script setup> is a compile-time syntactic sugar for using Composition API inside Single-File Components (SFCs). So you can use as usual: <script>...</script>, with your composition api code. And don't forget import style file: import 'vue-tinder/lib/style.css'

Got it, So I need to do options api for this. I need to refactor my code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants