vimeshjs / vimesh-ui

Vimesh UI is an ultra lightweight library to build UI components for Alpine.js
MIT License
125 stars 5 forks source link

Puzzle #18

Open ericxin1982 opened 9 months ago

ericxin1982 commented 9 months ago

image image

Hi @xinjie-zhang

Sorry to bother you, I try to create a top tree object to organize the data object for each x-data need, and I found vimesh-ui cannot read that, and vimesh-ui x-data source must be inline or created by alpine.data that way, how I can solve this?

thanks Eric Xin

ericxin1982 commented 9 months ago

image I changed to this way, it works. But I have another concern, the x-init would it would trigger twice.

image

Thanks Eric Xin

ericxin1982 commented 9 months ago

I do not use dynamic html feature, I just used static html inside.

ericxin1982 commented 9 months ago

image image

I tried it in a simple component, it is the same, init run twice.

Thanks Eric Xin

xinjie-zhang commented 9 months ago
  1. please do not bind data in component definition.
    <template ... x-data="put default static value here, but do not bind to external variable">..
  2. avoid to use x-init in template, you could use onMounted, please refer to examples/spa/app.html
ericxin1982 commented 9 months ago

Excellent.

Thanks Eric Xin

ericxin1982 commented 9 months ago

Hi @xinjie-zhang

I have a further question, sometimes you would define x-data for component definition, sometimes you would define x-data for component instance only, what is the standard I should follow?

Thanks Eric Xin