20
loading...
This website collects cookies to deliver better user experience
var model_data = {
js_frameworks: [‘Vue’, ‘Svelte’, ‘Riot’, ‘Hyperapp’, ‘Alpine’]
};
var vm = new Vue({
el: ‘#app’,
data: model_data
});
el
parameter connects the view model layer to any element in our view using the element’s ID. In this case, we bind our view model layer to an element whose ID attribute value is app
. The data parameter then connects the view model layer to the model. <div id=”app”>
<ul>
<li v-for=”framework in js_frameworks”>{{framework}}</li>
</ul>
</div>
v-for
to create a for loop to loop through the data and display it as a list.<script>
let name = "Samson";
</script>
<main>
<input bind:value="{name}" />
<p>My name is {name}.</p>
</main>
<style>
p {
color: red;
}
</style>
bind
attribute.name
holds. It inserts the text into the paragraph below the text box as well.name
holds and the value inserted into the paragraph changes. In our style, we made the color of our paragraph text red.<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js" defer></script>
x-data
x-init
x-show
x-bind
x-on
x-if
x-for
x-model
x-text
x-html
x-ref
x-transition
x-spread
x-cloak