Menu

Vue.js Explained: Reactivity Without the Boilerplate
📰

Vue.js Explained: Reactivity Without the Boilerplate

DEV Community: vue·The Practical Developer·about 15 hours ago
#JeG7UGTx
#devtovue#devto#dev#value#computed
Reading 0:00
15s threshold

Introduction

Vue.js is a front-end framework for building interactive web pages — the same job as React, with a gentler learning curve. Its core promise is reactivity: change your data, and the page updates itself, without you touching the DOM by hand.

If you know basic HTML and JavaScript, you can build something real in Vue within an afternoon.

Your first reactive value

Vue's ref wraps a value so Vue can watch it. Change the value, and anything displaying it updates automatically.

<script setup > import { ref } from ' vue '

const count = ref ( 0 )

function increment () { count . value ++ } </script>

<template> <button @ click= "increment" > Clicked {{ count }} times </button> </template>

Enter fullscreen mode

Exit fullscreen mode

Two things to notice. First, count.value in the script, but just count in the template — Vue unwraps refs in templates for you. Second, @click is Vue's shorthand for listening to a click event.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.