view.jsx 531 B

12345678910111213141516171819
  1. import { h, ref, computed } from 'vue'
  2. import { formInputViewProps } from '../../form-input-props'
  3. export default {
  4. props: formInputViewProps,
  5. setup (props) {
  6. const show = ref(false)
  7. const trigger = () => {
  8. show.value = !show.value
  9. }
  10. const text = computed(() => h('span', {}, show.value ? props.modelValue : '******'))
  11. return () =>
  12. h('span', {}, [
  13. text.value,
  14. h('i', { class: 'el-icon-view', style: { marginLeft: '10px', cursor: 'pointer' }, onClick: trigger })
  15. ])
  16. }
  17. }