<!DOCTYPE html>
<html lang="en">
<head>
<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>Document</title>
</head>
<body>
<div id="revnum">
<!-- rev可以加括号,也可以不加,加括号是为了传参 -->
<!-- 点击“hello”实现逆序 -->
<h1 v-on:click="rev()">{{word}}</h1>
<!-- <h1>{{word}}转为{{word.split("").reverse().join("")}}</h1> -->
</div>
<script src="./vue2.6.14.js"></script>
<script>
let vm = new Vue({
el: "#revnum",
data: {
word: "hello",
},
methods: {
rev() {
this.word = this.word.split("").reverse().join("");
}
}
})
</script>
</body>
</html>