admin管理员组文章数量:1302982
So I have table which gets filled using vue.js v-for method:
<table>
<tr><th>Name</th><th>Surname</th></tr>
<tr v-for="user in users"><td>@{{user.name}}</td><td>@{{user.surname}}</td></tr>
</table>
And I need this table to be maximum 300px
in height, and if it gets longer, it bees scrollable.
So basically I need to set max-height
and overflow:auto
parameters in my css, but the problem is that the code does not "see" this table appropriately because it is rendered with vue.
So far I've tried just adding parameters in css and adding them dynamically after loading the table; none of these worked.
But, if I call $('table').height()
, it returns the actual height of the rendered table. Maybe I can use it somehow?
Would highly appreciate any possible help!
So I have table which gets filled using vue.js v-for method:
<table>
<tr><th>Name</th><th>Surname</th></tr>
<tr v-for="user in users"><td>@{{user.name}}</td><td>@{{user.surname}}</td></tr>
</table>
And I need this table to be maximum 300px
in height, and if it gets longer, it bees scrollable.
So basically I need to set max-height
and overflow:auto
parameters in my css, but the problem is that the code does not "see" this table appropriately because it is rendered with vue.
So far I've tried just adding parameters in css and adding them dynamically after loading the table; none of these worked.
But, if I call $('table').height()
, it returns the actual height of the rendered table. Maybe I can use it somehow?
Would highly appreciate any possible help!
Share edited Aug 8, 2016 at 13:08 Mi-Creativity 9,66410 gold badges40 silver badges48 bronze badges asked Aug 8, 2016 at 13:05 CoffeeCoffee 2,2339 gold badges32 silver badges57 bronze badges 2- I'm late to the party, but I recently published an open-source table wrapper ponent for Vue that does horizontal and vertical body scrolling. github./richardtallent/vue-scrolling-table – richardtallent Commented Jan 31, 2018 at 2:13
- 1 @richardtallent sweet! great job! – Coffee Commented Feb 2, 2018 at 12:07
2 Answers
Reset to default 7Can you wrap the table in a <div>
?
This way the div controls the scrolling and the table is free to go it's own way.
package.json
"cssnano-preset-default": {
"version": "4.0.7",
...
"postcss-calc": "^7.0.1",
Wrap <b-table
or <table>
with <template>
then <div>
and add css
table.vue
<!--wrapper--->
<template>
<div>
<b-table
<!--...--->
</b-table>
</div>
</template>
<script>
import { mapGetters, mapMutations } from "vuex";
export default {
name: "data-table",
props: ["pageSource"],
middleware: ["auth", "enable"],
puted: {
...mapGetters(["loggedInUser", "userSettings"]),
}
<!--...--->
}
</script
<!-- css at bottom of page -->
<style lang="scss" scoped>
.b-table {
max-height: calc(100vh - 300px);
overflow-y: auto;
}
</style>
本文标签: javascriptScrollable table with VuejsStack Overflow
版权声明:本文标题:javascript - Scrollable table with Vue.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741664587a2391231.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论