Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to support a v-data attribute #11564

Closed
pandichef opened this issue Aug 4, 2020 · 1 comment
Closed

Request to support a v-data attribute #11564

pandichef opened this issue Aug 4, 2020 · 1 comment

Comments

@pandichef
Copy link

What problem does this feature solve?

I recently started using Alpine.js. Its best feature - in my humble opinion - is the x-data attribute. It basically allows you to create a "nameless" component and define your data/state variables in the <div> tag.

What does the proposed API look like?

<div v-data='{myvar: "Off"}'>
  <button type="button" v-on:click="myvar = (myvar === 'Off') ? 'On' : 'Off'">{{ myvar }}</button>
</div>

instead of...

<div id="app">
  <button type="button" v-on:click="myvar = (myvar === 'Off') ? 'On' : 'Off'">{{ myvar }}</button>
</div>
<script>
  var app = new Vue({
    el: '#app',
    data: {
      myvar: 'Off',
    },
  });
</script>
@posva
Copy link
Member

posva commented Aug 4, 2020

See #7325

@posva posva closed this as completed Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants