基础的示例

main
RogerWork 1 year ago
parent 73dcc76ec8
commit 7affee848b
  1. 2
      demo/hello-vue.html
  2. 27
      demo/v-html.html
  3. 35
      demo/v-on.html
  4. 29
      demo/v-show.html
  5. 39
      demo/v-text和插值语法.html

@ -4,10 +4,10 @@
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE-edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hello-Vue</title>
<link rel="stylesheet" href="https://unpkg.com/element-plus/dist/index.css"/>
<script src="https://unpkg.com/vue@3.2.24/dist/vue.global.js"></script>
<script src="https://unpkg.com/element-plus"></script>
<title>Hello-Vue</title>
</head>
<body>
<div id="app">

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edfe">
<script src="https://unpkg.com/vue@3.3.4/dist/vue.global.js"></script>
<title>v-html</title>
</head>
<body>
<div id="app">
<p v-text="html_content"></p>
<!-- 观察v-text和v-html的区别 -->
<p v-html="html_content"></p>
</div>
<script type="text/javascript">
const App = {
data() {
return {
html_content: "<a href='http://www.baidu.com'>百度</a>"
}
}
}
Vue.createApp(App).mount("#app")
</script>
</body>
</html>

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edfe">
<script src="https://unpkg.com/vue@3.3.4/dist/vue.global.js"></script>
<title>v-on</title>
</head>
<body>
<div id="app">
<input type="button" value="点击执行" v-on:click="click_action"><br>
<input type="button" value="双击执行" @dblclick="double_action">
</div>
<script type="text/javascript">
const App = {
data() {
return {
count: 0,
}
},
methods: {
click_action: function () {
alert('执行方法成功')
},
double_action: function () {
alert("当前数值为:" + this.count+', 再次双击将+1')
this.count++
}
}
}
Vue.createApp(App).mount("#app")
</script>
</body>
</html>

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edfe">
<script src="https://unpkg.com/vue@3.3.4/dist/vue.global.js"></script>
<title>v-show</title>
</head>
<body>
<div id="app">
<img src="https://v2.cn.vuejs.org/images/logo.svg" alt="" v-show="true">
<img src="https://v2.cn.vuejs.org/images/logo.svg" alt="" v-show="false">
<h2 v-show="isShow">对象形式</h2>
<h2 v-show="age>18">{{ age }}</h2>
</div>
<script>
const App = {
data() {
return {
isShow: true,
age: 20,
}
}
}
Vue.createApp(App).mount("#app")
</script>
</body>
</html>

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edfe">
<script src="https://unpkg.com/vue@3.3.4/dist/vue.global.js"></script>
<!-- <script src="https://unpkg.com/vue@2.7.14/dist/vue.js"></script>-->
<title>v-text和插值语法</title>
</head>
<body>
<div id="app">
<!-- v-text -->
<h2 v-text="message+'!'">测试</h2>
<h2 v-text="message+info">测试</h2>
<!-- 插值语法-->
<h2>{{ message }}!!{{ info }}</h2>
</div>
<script>
// // 此处是Vue2的写法,所以上面引用需要引用Vue2
// const App = new Vue({
// el: '#app',
// data: {
// message: '您好',
// }
// })
// 此处是Vue3的写法, 引用时需要引用Vue3
const App = {
data() {
return {
message: '您好',
info: '信息',
}
}
}
Vue.createApp(App).mount('#app')
</script>
</body>
</html>
Loading…
Cancel
Save