<script>
import layer from '../../common/layer.ts';
export default {
  components: {},
  data() {
    return{
        show: false,
        count: 0,
        open: function() {
            this.show = true;
            layer.open({
                title: "弹窗",
                id: "layer-test",
                icon: "icon-search",
                area: {
                    width: '400px',
                    height: '400px',
                },
                btn: {
                    confirm: "确定",
                    cancel: "取消"
                },
                confirm: ()=> {
                    this.show = false;
                },
                cancel: ($event)=>{
                    this.show = false;
                     console.log($event)
                }
            });
        }.bind(this),
        open2: function() {
            this.show = true;
            layer.open({
                title: "弹窗2",
                id: "layer-test2",
                icon: "icon-search",
                area: {
                    width: '400px',
                    height: '400px',
                },
                btn: {
                    confirm: "确定",
                    cancel: "取消"
                },
                confirm: ()=> {
                    this.show = false;
                },
                cancel: ($event)=>{
                    this.show = false;
                    layer.closeAll();  
                }
            });
        }.bind(this),
        openMsg: function() {
            layer.msg('提示消息', {type: 'success', time: 2000})
        }.bind(this),
        openLoad: function() {
            let index = layer.load({message: '加载中...'});
            setTimeout(()=>{
                layer.close(index);
            },3000)
        }.bind(this)
    }
  }
}
</script>
<style>.layer-display{display:none}</style>
# Layer 弹窗
弹窗层。

## 基础用法
基础的按钮用法。
:::demo 使用`f-icon`嵌入图标
````html
<efly-button @click="open">打开弹窗</efly-button>
<div id="layer-test" class="layer-display">
    弹窗测试
    <efly-button @click="openLoad">打开提示</efly-button>
    <efly-button @click="open2">打开弹窗2</efly-button>
    <div id="layer-test2" class="layer-display">
        弹窗测试2
    </div>
</div>
<script>
import layer from '../../common/layer.ts';
export default {
  components: {},
  data() {
    return{
        show: false,
        open: function() {
            this.show = true;
            layer.open({
                title: "弹窗",
                id: "layer-test",
                icon: "icon-search",
                area: {
                    width: '400px',
                    height: '400px',
                },
                btn: {
                    confirm: "确定",
                    cancel: "取消"
                },
                confirm: ()=> {
                    this.show = false;
                },
                cancel: ($event)=>{
                    this.show = false;
                }
            });
        }.bind(this)
    }
  }
}
</script>
````
:::

## 参数说明
| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| title     | 标题   | String  |     —        |    标题     |
| id     | 节点id   | String  |     —        |    —     |
| icon     | 图标   | String  |     —        |    —     |
| area.width     | 弹窗宽度   | String  |      —         |    —    |
| area.height     | 弹窗高度   | String  |      —        |    —    |
| btn.confirm     | 按钮确定文本   | String  |      —    |    确定    |
| btn.cancel     | 按钮取消文本（默认不显示）   | String  |      —         |    —    |
| confirm     | 确定回调事件   | String  |      —         |    —    |
| cancel      | 取消回调事件   | String  |      —         |    —    |

## cancel($event)回调
| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| type      | 类型   | String  |      button/icon        |    —    |


## 弹窗消息提示
layer.msg(content, options)

:::demo 使用`f-icon`嵌入图标
````html
<efly-button @click="openMsg">打开提示</efly-button>
<script>
import layer from '../../common/layer.ts';
export default {
  components: {},
  data() {
    return{
        
    }
  },
  methods: {
    openMsg: function() {
        layer.msg('提示消息', {type: 'success', time: 2000});
    }
  }
}
</script>
````
:::

## 参数说明
| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| content     | 提示信息   | String  |     —        |    —     |
| type     | 类型   | string  | success \| warning \| error \| info |    —     |
| time     | 时间   | Number  | — |    2000     |






## 加载弹窗
layer.load(options?)

:::demo 使用`f-icon`嵌入图标
````html
<efly-button @click="openLoad">打开加载</efly-button>
<script>
import layer from '../../common/layer.ts';
export default {
  components: {},
  data() {
    return{
        
    }
  },
  methods: {
    openLoad: function() {
        let index = layer.load();
        setTimeout(()=>{
            layer.close(index);
        },4000)
    }
  }
}
</script>
````
:::

## 参数说明
| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| options.message     | 类型   | string  | — |    —     |
| options.time     | 时间   | Number  | — |    —     |
