zyronon / douyin

Vue3 + Pinia 仿抖音,Vue 在移动端的最佳实践 . Imitate TikTok ,Vue Best practices on Mobile
https://dy.ttentau.top/
GNU General Public License v3.0
9.92k stars 2.73k forks source link

Question: v-love指令哪里来的? #119

Closed hzz4j closed 3 weeks ago

hzz4j commented 3 weeks ago

问题

在看视频无线下拉的实现,我看到一个v-love指令,我在main.ts没有看到你注册这个指令,查看了一下依赖包,也没有相关的该指令的包,请问你这个v-love是在哪里实现的?

SlideList.vue组件下调用SlideVerticalInfinite.vue组件,我看到有一个v-love.指令v-love="props.uniqueId"

<template>
  <SlideVerticalInfinite
    ref="listRef"
    v-love="props.uniqueId"
    :id="props.uniqueId"
    :uniqueId="props.uniqueId"
    name="infinite"
    :active="props.active"
    :loading="baseStore.loading"
    v-model:index="state.index"
    :render="render"
    :list="state.list"
    @loadMore="loadMore"
    @refresh="() => getData(true)"
  />
</template>

我的尝试

尝试1

在main.ts寻找注册指令,只发现了你实现的v-click,app.directive('click', vClick)

const vClick = useClick()
// ...
app.directive('click', vClick)

尝试2

在你的依赖中只看到v-lazy依赖的包"@jambonn/vue-lazyload": "1.0.9",

  "dependencies": {
    "@jambonn/vue-lazyload": "1.0.9",
    "axios": "^1.6.8",
    "axios-mock-adapter": "^1.22.0",
    "core-js": "3.21.1",
    "libarchive-wasm": "^1.1.0",
    "mockjs": "^1.1.0",
    "pinia": "^2.1.7",
    "vue": "3.4.21",
    "vue-router": "4.3.0"
  },

不太清楚你的v-love是从哪里来的,可以告知一下吗?Thanks : )

zyronon commented 3 weeks ago

https://github.com/zyronon/douyin/blob/master/src/utils/mixin.ts#L106