loginForm.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <view class="login-form">
  3. <view class="form-item">
  4. <view class="form-label">
  5. 手机号
  6. </view>
  7. <view class="form-body">
  8. <image :src="$static('images/icon/username.png')" class="icon" />
  9. <input
  10. v-model="form.username"
  11. placeholder="请输入账号"
  12. placeholder-class="wk-placeholder placehoder"
  13. maxlength="11"
  14. class="input-core"
  15. @input="handleChange">
  16. </view>
  17. </view>
  18. <view class="form-item">
  19. <view class="form-label">
  20. 密码
  21. </view>
  22. <view class="form-body">
  23. <image :src="$static('images/icon/password.png')" class="icon" />
  24. <input
  25. v-model="form.password"
  26. password
  27. placeholder="请输入密码"
  28. placeholder-class="wk-placeholder placehoder"
  29. maxlength="20"
  30. class="input-core"
  31. @input="handleChange">
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. name: 'LoginForm',
  39. props: {
  40. value: {
  41. type: Object,
  42. required: true
  43. }
  44. },
  45. data() {
  46. return {
  47. form: {
  48. username: '',
  49. password: ''
  50. }
  51. }
  52. },
  53. watch: {
  54. value: {
  55. handler() {
  56. this.form = this.value || {username: '', password: ''}
  57. },
  58. immediate: true,
  59. deep: true
  60. }
  61. },
  62. methods: {
  63. handleChange() {
  64. this.$emit('input', this.form)
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped lang="scss">
  70. @import '../style/formItem.scss';
  71. .login-form {
  72. width: 100%;
  73. margin-top: 50rpx;
  74. }
  75. </style>