Comments (11)
@jdosullivan This might be too late to help you, but in case it helps others I thought I'd reply. You can just put the following in your client-entry.js, so it is only referenced on the client.
var infiniteScroll = require('vue-infinite-scroll');
Vue.use(infiniteScroll);
from vue-infinite-scroll.
add configration in ‘plugins’ of the nuxt.config.js file, and custom this file in plugins directory
import Vue from 'vue';
import infiniteScroll from 'vue-infinite-scroll';
export default () => {
Vue.use(infiniteScroll)
}
from vue-infinite-scroll.
from vue-infinite-scroll.
You can make a plugin which only runs client side
from vue-infinite-scroll.
it does show up and works fine on yarn dev but it breaks completely on a production environment
from vue-infinite-scroll.
I'm using nuxt and am not sure how to add a directive to only run client-side. I've naively tried to use this.use(inifiniteScroll)
inside my mount
function but this.use
is not a function.
from vue-infinite-scroll.
it does show up and works fine on yarn dev but it breaks completely on a production environment
do you have a solution?I have encountered the same problem
Have a try with client-only.I solve it by it
<client-only> <infinite-loading></infinite-loading> </client-only>
from vue-infinite-scroll.
My answer is working with NuxtJs
- Add
vue-infinite-scroll
as a plugin on your plugins folder - Add this to nuxt.config.js file => { src: '@/plugins/vue-infinite-scroll.js', ssr: false }
- Do not add
vue-infinite-scroll
as a directive
Note: If you import it from another files except plugins, you will get an error
from vue-infinite-scroll.
@GuvanchBayryyyev I tried to follow your steps but stopped at step 3
How can I not use it as a directive? If this package has only directive.
from vue-infinite-scroll.
Ok, it worked!
I loaded it as a plugin in NuxtJS and added v-infinite outside of <no-ssr>
tag
<div v-infinite-scroll="loadMore" infinite-scroll-distance="10">
</div>
from vue-infinite-scroll.
@DavertMik could you share your code? I would really appreciate your help since I just cant get it to work 😅
(The API call is supposed to use ssr.)
My component:
<template>
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-3 lg:grid-cols-5 gap-4" v-infinite-scroll="fetchData">
<div v-for="book in books" :key="book.id">
<img class="rounded-t-lg w-80 mx-auto" :src="`${ book.image_server }${book.id}/cover.jpg`"/>
<div class="rounded-b-lg bg-gray-700 h-14 px-2 leading-5 flex justify-center items-center">
<p class="line-clamp-2">{{book.title}}</p>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'BookList',
data: () => ({
books: [],
page: 0,
}),
methods: {
fetchData() {
console.log("Triggered");
this.$fetch();
}
},
async fetch() {
let books = await this.$axios.$post('https://www.open-books.com/api/getBook', {
search: {
text: '',
page: this.page,
sort: 0,
}
});
this.books.push(...books.results)
},
}
</script>
from vue-infinite-scroll.
Related Issues (20)
- not support typescript
- Set "infinite-scroll-immediate-check" to false is not working if the prop sent as boolean HOT 1
- 滚动到底部加载一次后,就开始无限加载,直至全部加载完成bug
- Load callback checking fail when using async function
- 【天坑】此指令不能和v-else一起使用 HOT 3
- 请问当把这个指令使用在弹框这样一开始没有渲染的dom里面这样的情况怎么解决呢? HOT 1
- Firing without reaching bottom HOT 4
- 在微信和QQ内滑动失效?
- 在弹窗内无法使用 HOT 5
- vue-infinite-scroll支持vue3吗 HOT 7
- Stop calling api when I scroll down HOT 1
- 弹框中无法滚动加载,只有把列表封装成组件,可调用正常 HOT 2
- Problems with "page" variable
- Vue 3 support HOT 1
- 还是不能v-if下使用啊,v-show也不行 HOT 1
- Passive scroll listener
- 支持vue3的办法 How to support vue3
- not working in table td element HOT 1
- test
- example中的vue已经无法下载了
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-infinite-scroll.