🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 官方文档: https://uniapp.dcloud.io/component/button.html ## 语法: ``` <button type="primary">提交按钮</button> ``` ## 提交表单 form-type="submit" ``` <button type="primary" form-type="submit">提交按钮</button> ``` ``` <form @submit="sub" @reset=""> <form/> //提交表单 sub为函数 ``` ## picker 用input隐藏方法提交 ``` <picker mode="selector" :range="lanuage" @change="picChange"> <view>{{lanuage[index]}}</view> <input type="text" name="lan" :value="lanuage[index]" hidden /> </picker> ``` ## 代码案例: ``` <template> <view class="content"> <form @submit="sub"> <input class="uni-input" name="test" type="text" value="" /> <!-- 弹窗选择 --> <text>picker:</text> <picker mode="selector" :range="lanuage" @change="picChange"> <view>{{lanuage[index]}}</view> <input type="text" name="lan" :value="lanuage[index]" hidden /> </picker> <!-- 弹窗选择 --> <button type="primary" form-type="submit">提交按钮</button> </form> </view> </template> <script> export default { data() { return { lanuage:['java','php','js','css','c++'], index:0 //获取数组下标 } }, onLoad() { }, methods: { sub:function(e){ console.log(e); }, picChange(e){ this.index=e.detail.value; //返回数组下标 } } } </script> <style> input{ background-color:#999799; } </style> ```