permiMode.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { ComponentOptions, defineComponent } from 'vue'
  2. import type { IPermiObj } from './type'
  3. import { css } from '@emotion/css'
  4. import 'vant/lib/index.css';
  5. import { Button } from 'vant';
  6. const MyComponent = (prop: IPermiObj | Boolean, permi: number): ComponentOptions =>
  7. defineComponent({
  8. name: 'MyComponent',
  9. components: {
  10. [Button.name as string]: Button
  11. },
  12. setup() {
  13. const obj = prop as IPermiObj
  14. const FixDivMode = css`
  15. width: 100vw;
  16. height: 100vh;
  17. background-color: rgba(255, 255, 255, 0.5);
  18. position: fixed;
  19. left: 0;
  20. top: 0;
  21. `
  22. const FixTips = css`
  23. font-size: 14px;
  24. position: absolute;
  25. bottom: 200px;
  26. text-align: center;
  27. width: 100%;
  28. color: red;
  29. `
  30. const FixBtn = css`
  31. font-size: 16px;
  32. margin-top: 10px;
  33. width: 160px;
  34. height: 50px;
  35. white-space: nowrap;
  36. `
  37. const handleClick = () => {
  38. console.log(permi)
  39. }
  40. return {
  41. FixTips,
  42. FixDivMode,
  43. FixBtn,
  44. handleClick,
  45. obj
  46. }
  47. },
  48. render() {
  49. console.log(prop)
  50. return prop && <div class={this.FixDivMode}>
  51. <div class={this.FixTips}>
  52. <div>
  53. {this.obj.text}
  54. </div>
  55. <div>
  56. <van-button class={this.FixBtn} onClick={this.handleClick}>{this.obj.btnText}</van-button>
  57. </div>
  58. </div>
  59. </div>
  60. },
  61. })
  62. export default MyComponent