tabulator: Vue Composition API not working
https://tabulator.info/docs/5.4/frameworks
As with many newbie simpley copy and paste the code from Composition API example for Vue 3.
No devs will able to understand what is gong on and create a negative experience that made us spent hours without success.
[plugin:vite:vue] [@vue/compiler-sfc] 'return' outside of function. (18:2)
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 21 (4 by maintainers)
@olifolkerd Apologies after a little more real-world testing there is actually a valid issue
I’ll try my best to give an accurate description.
Take the basic example above this is not using Tabulator if you run this SFC Playground Demo
You can see an api call has been sent, the data has been returned and the
tableDataref has automatically updated it’s value on the page, this is an example of everything working as expected.If we now introduce Tabulator :
What happens now is the api call is made, the data in the table is updated as you would expect but the
tableDatareference does not update as you would expect indicating that the definition has lost reactivity.Next I tried to confirm it was Tabulator breaking the reactivity. So I looked in
ReactiveData.jsto see how it worked and noticed you were re-defining methods temporarily then running a .apply to call the original method once you had done your processing. I found a method you hadn’t redefined so I created an example with both anObject.assignand a.pushthe theory being that since Tabulator doesn’t touchObject.assignit will retain reactivity and on the flip side using .push will break reactivity but will still update the table content.This confirmed that it related to the Tabulator reactivity module, so I stepped through the code for the
.push. As expected it does the standard processing then does a.applyto call the vanilla method passing in the context and argumentsresult = self.origFuncs.push.apply(data, arguments);Which then runs Vue’s version which does a very similar thing…
From the minimal debugging I have conducted it looks like the tabulator data reactivity module runs it’s version of
.pushPart of that process includes aself.blockto prevent infinite looping.It then runs a
.apply- which triggers a call to Vue which does it’s own version of.apply( as seen in the snippet above) which in turn triggers another instance of the tabular reactivity module but since the very first instance added aself.blockthe processing fails theifstatement which means Vue’s version of .apply is essentially terminated by tabulators function.I hope that makes as much sense as it does in my head!
I got a small test working locally with Nuxt and vue 3
Hope this help, This project seems to be a really nice project
What I don’t understand why they label it as suggested feature and not as bug fix.
Seem to have the same issue, the header is appear but tableData is not showing.