add refs example
This commit is contained in:
parent
10a51af597
commit
83c735ea33
|
@ -1,18 +1,19 @@
|
|||
const app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
currentUserInput: '',
|
||||
message: 'Vue is great!',
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
saveInput(event) {
|
||||
this.currentUserInput = event.target.value;
|
||||
data() {
|
||||
return {
|
||||
currentUserInput: "",
|
||||
message: "Vue is great!",
|
||||
};
|
||||
},
|
||||
setText() {
|
||||
this.message = this.currentUserInput;
|
||||
methods: {
|
||||
saveInput(event) {
|
||||
this.currentUserInput = event.target.value;
|
||||
},
|
||||
setText() {
|
||||
//this.message = this.currentUserInput;
|
||||
this.message = this.$refs.userText;
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
app.mount('#app');
|
||||
app.mount("#app");
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vue Basics</title>
|
||||
<link
|
||||
href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@400;700&display=swap" rel="stylesheet" />
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
<script src="https://unpkg.com/vue@next" defer></script>
|
||||
<script src="app.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<h1>Vue Behind The Scenes</h1>
|
||||
<h1>Vue Behind The Scenes</h1>
|
||||
</header>
|
||||
<section id="app">
|
||||
<h2>How Vue Works</h2>
|
||||
<input type="text" @input="saveInput">
|
||||
<button @click="setText">Set Text</button>
|
||||
<p>{{ message }}</p>
|
||||
<h2>How Vue Works</h2>
|
||||
<input type="text" ref="userText">
|
||||
<button @click="setText">Set Text</button>
|
||||
<p>{{ message }}</p>
|
||||
</section>
|
||||
</body>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
Reference in New Issue