el-input只能输入数字而且最高为100
时间: 2023-05-13 16:07:23 浏览: 93
您可以使用以下代码来限制el-input只能输入数字且最高为100:
<el-input v-model="inputValue" :maxlength="3" @input="handleInput"></el-input>
<script>
export default {
data() {
return {
inputValue: ''
}
},
methods: {
handleInput(val) {
const reg = /^[0-9]*$/;
if (!reg.test(val)) {
this.inputValue = '';
} else if (val > 100) {
this.inputValue = '100';
}
}
}
}
</script>
关于lua closure factory的完整代码,您可以参考以下示例:
function createClosureFactory()
local count = 0
return function()
count = count + 1
return function()
return count
end
end
end
local closureFactory = createClosureFactory()
local closure1 = closureFactory()
local closure2 = closureFactory()
print(closure1()) -- 输出1
print(closure2()) -- 输出2
至于中文加密,您可以使用以下代码来实现:
function encrypt(str)
local result = ''
for i = 1, #str do
local char = string.sub(str, i, i)
local byte = string.byte(char)
result = result .. string.format('%02X', byte)
end
return result
end
local str = '中文加密'
print(encrypt(str)) -- 输出E4B8ADE69687E5A5BDE58A82
阅读全文