Demo 在线地址:
https://sx00xs.github.io/test/22/index.html
---------------------------------------------------------------
ide: vscode
文件格式:.vue
解析:(待补)
<template> <div id="app"> <input type="text" class="f-text" v-model="num1" @keyup="handleNum1"> <strong>vs</strong> <input type="text" class="f-text" v-model="num2" @keyup="handleNum2"> <input @click="handleBignum" type="button" value="最大的数是 »" class="f-btn"><span>{{which}}</span> </div> </template> <script> export default { data:function(){ return{ num1:'', num2:'', which:'?' } }, methods:{ handleNum1(){ this.num1=this.num1.replace(/[^d]/,''); }, handleNum2(){ this.num2=this.num2.replace(/[^d]/,''); }, handleBignum(){ (this.num1=='' || this.num2=='') ? alert('请输入数字!') : this.which=Math.max(this.num1,this.num2); } } } </script>