# 15_前端开发技巧
URL: /%E6%96%87%E6%A1%A3/04.%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3/01.%20%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/01.%20%E5%9F%BA%E7%A1%80%E8%A7%84%E8%8C%83/08.%20%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91%E6%8A%80%E5%B7%A7


# 禁用表单所有组件

通过 BaseForm disabled 属性进行表单全局禁用控制

```
useForm({
  labelWidth: 120,
  //禁用表单所有组件
  disabled:true,
});
```

效果如下
![](https://img.kancloud.cn/7f/93/7f93a8d2f801d4a1780dd13e810ecda1_2213x265.png)

# 弹框内下拉框错位如何处理，如下图

![](https://img.kancloud.cn/09/aa/09aaeab341107575b4c43a6aba789e93_868x487.png)
处理方法,使用
getPopupContainer: (node) => document.body
或者
getPopupContainer: (node) => node.parentNode

```
{
  field: 'ruleConditions',
  label: '条件规则',
  required: true,
  component: 'ApiSelect',
  componentProps: {
    api: ajaxGetDictItems,
    params:{code:'rule_conditions'},
    labelField: 'text',
    valueField: 'value',
    getPopupContainer: (node) => document.body,
  },
},
```

使用后效果如下
![](https://img.kancloud.cn/f1/5e/f15e1cf2fc7af7e305bb7f7e261cb600_847x563.png)

# Drawer（抽屉）宽度自适应的解决方案

## 使用 useDrawerAdaptiveWidth

参考 `UserDrawer.vue` 的实现。

``` js
// step1 引入useDrawerAdaptiveWidth方法
import {useDrawerAdaptiveWidth} from '/@/hooks/jeecg/useAdaptiveWidth'
// step2 获取到adaptiveWidth
const {adaptiveWidth} = useDrawerAdaptiveWidth()
```

``` html
<!-- step3 在页面上使用 -->
<BasicDrawer
    @register="registerDrawer"
    :width="adaptiveWidth"
/>
```

## 自定义宽度范围

`useDrawerAdaptiveWidth` 定义了一些默认的自适应宽度，可以应对大多数情况，但是如果当默认的自适应宽度范围无法满足的需求时，就可以自己实现自适应宽度了。
你可以参考下图的默认配置进行修改。
![](https://img.kancloud.cn/69/ee/69eec1b0409d324adea291aedb777d3b_441x271.png)
