Vue Component Example: Displaying a Message
<!DOCTYPE html>
<html>
<head>
<title>Vue Example</title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app">
<h1>{{ message }}</h1>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
});
</script>
</body>
</html>
This example demonstrates creating a Vue instance attached to the `#app` element. The `data` object holds the `message` property, which is displayed in the `h1` element using curly brackets `{{ }}`. Vue replaces the `{{ message }}` expression with the value "Hello Vue!" when the page loads.
<p>You can test this example by saving it as an HTML file and opening it in a web browser.</p>
原文地址: https://www.cveoy.top/t/topic/pEeZ 著作权归作者所有。请勿转载和采集!