text: import{_ as n,c as s,o as a,d as t}from"./app.8de9463f.js";const g='{"title":"element ui select\u6846\u5B9E\u73B0ctrl+c \u548Cctrl+v\u7684\u529F\u80FD","description":null,"frontmatter":{"title":"element ui select\u6846\u5B9E\u73B0ctrl+c \u548Cctrl+v\u7684\u529F\u80FD","description":null,"date":"2021-07-21T00:00:00.000Z","tags":["element_ui"]},"headers":[],"relativePath":"posts/element_ui_select_ctrl_c_ctrl_v.md","lastUpdated":1647305989506}',p={},o=t(`<div class="language-javascript"><pre><code> <span class="token operator">&lt;</span>template<span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span>div<span class="token operator">&gt;</span>
      <span class="token operator">&lt;</span>el<span class="token operator">-</span>select
        ref<span class="token operator">=</span><span class="token string">&quot;select&quot;</span>
        placeholder<span class="token operator">=</span><span class="token string">&quot;\u8BF7\u9009\u62E9\u4E3B\u98DF&quot;</span>
        filterable
        id<span class="token operator">=</span><span class="token string">&quot;food&quot;</span>
        @keydown<span class="token punctuation">.</span>ctrl<span class="token punctuation">.</span><span class="token number">67.</span>native<span class="token operator">=</span><span class="token string">&quot;copyFocusedBoxContent&quot;</span>
        @paste<span class="token punctuation">.</span>native<span class="token punctuation">.</span>capture<span class="token punctuation">.</span>prevent<span class="token operator">=</span><span class="token string">&quot;handlePaste&quot;</span>
        v<span class="token operator">-</span>model<span class="token operator">=</span><span class="token string">&quot;formData.food&quot;</span>
        clearable
        multiple
        collapse<span class="token operator">-</span>tags
      <span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span>el<span class="token operator">-</span>option
          v<span class="token operator">-</span><span class="token keyword">for</span><span class="token operator">=</span><span class="token string">&quot;item in options&quot;</span>
          <span class="token operator">:</span>key<span class="token operator">=</span><span class="token string">&quot;item.label&quot;</span>
          <span class="token operator">:</span>label<span class="token operator">=</span><span class="token string">&quot;item.label&quot;</span>
          <span class="token operator">:</span>value<span class="token operator">=</span><span class="token string">&quot;item.code&quot;</span>
        <span class="token operator">&gt;</span>
        <span class="token operator">&lt;</span><span class="token operator">/</span>el<span class="token operator">-</span>option<span class="token operator">&gt;</span>
      <span class="token operator">&lt;</span><span class="token operator">/</span>el<span class="token operator">-</span>select<span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span><span class="token operator">/</span>div<span class="token operator">&gt;</span>
  <span class="token operator">&lt;</span><span class="token operator">/</span>template<span class="token operator">&gt;</span>
   
  <span class="token operator">&lt;</span>script<span class="token operator">&gt;</span>
  <span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
    methods<span class="token operator">:</span> <span class="token punctuation">{</span>
      <span class="token function">handlePaste</span><span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">const</span> inputValueArr <span class="token operator">=</span> e<span class="token punctuation">.</span>clipboardData<span class="token punctuation">.</span><span class="token function">getData</span><span class="token punctuation">(</span><span class="token string">&quot;Text&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">split</span><span class="token punctuation">(</span><span class="token string">&quot;,&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
   
        <span class="token keyword">const</span> recordIndex <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">;</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">const</span> e <span class="token keyword">of</span> <span class="token keyword">this</span><span class="token punctuation">.</span>options<span class="token punctuation">)</span> <span class="token punctuation">{</span>
          recordIndex<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>e<span class="token punctuation">.</span>code<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
        <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">const</span> f <span class="token keyword">of</span> inputValueArr<span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token keyword">if</span> <span class="token punctuation">(</span>recordIndex<span class="token punctuation">.</span><span class="token function">includes</span><span class="token punctuation">(</span>f<span class="token punctuation">)</span> <span class="token operator">&amp;&amp;</span> <span class="token operator">!</span><span class="token keyword">this</span><span class="token punctuation">.</span>formData<span class="token punctuation">.</span>food<span class="token punctuation">.</span><span class="token function">includes</span><span class="token punctuation">(</span>f<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            <span class="token keyword">this</span><span class="token punctuation">.</span>formData<span class="token punctuation">.</span>food<span class="token punctuation">.</span><span class="token function">push</span><span class="token punctuation">(</span>f<span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
   
      <span class="token function">copyFocusedBoxContent</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">$copyText</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>formData<span class="token punctuation">.</span>food<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span>
          <span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
            <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">$message</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
              message<span class="token operator">:</span> <span class="token string">&quot;Copied&quot;</span><span class="token punctuation">,</span>
              duration<span class="token operator">:</span> <span class="token number">200</span><span class="token punctuation">,</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">(</span><span class="token parameter">e</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
            <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">$message</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
              message<span class="token operator">:</span> <span class="token string">&quot;Can not copy&quot;</span><span class="token punctuation">,</span>
              duration<span class="token operator">:</span> <span class="token number">200</span><span class="token punctuation">,</span>
            <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token punctuation">}</span>
        <span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token function">data</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">return</span> <span class="token punctuation">{</span>
        formData<span class="token operator">:</span> <span class="token punctuation">{</span>
          food<span class="token operator">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        options<span class="token operator">:</span> <span class="token punctuation">[</span>
          <span class="token punctuation">{</span>
            code<span class="token operator">:</span> <span class="token string">&quot;11&quot;</span><span class="token punctuation">,</span>
            label<span class="token operator">:</span> <span class="token string">&quot;11-\u9EC4\u91D1\u7CD5&quot;</span><span class="token punctuation">,</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">{</span>
            code<span class="token operator">:</span> <span class="token string">&quot;12&quot;</span><span class="token punctuation">,</span>
            label<span class="token operator">:</span> <span class="token string">&quot;12-\u53CC\u76AE\u5976&quot;</span><span class="token punctuation">,</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">{</span>
            code<span class="token operator">:</span> <span class="token string">&quot;13&quot;</span><span class="token punctuation">,</span>
            label<span class="token operator">:</span> <span class="token string">&quot;13-\u86B5\u4ED4\u714E&quot;</span><span class="token punctuation">,</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">{</span>
            code<span class="token operator">:</span> <span class="token string">&quot;14&quot;</span><span class="token punctuation">,</span>
            label<span class="token operator">:</span> <span class="token string">&quot;14-\u9F99\u987B\u9762&quot;</span><span class="token punctuation">,</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">{</span>
            code<span class="token operator">:</span> <span class="token string">&quot;15&quot;</span><span class="token punctuation">,</span>
            label<span class="token operator">:</span> <span class="token string">&quot;15-\u5317\u4EAC\u70E4\u9E2D&quot;</span><span class="token punctuation">,</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
          <span class="token punctuation">{</span>
            code<span class="token operator">:</span> <span class="token string">&quot;115&quot;</span><span class="token punctuation">,</span>
            label<span class="token operator">:</span> <span class="token string">&quot;115-\u4E4C\u51AC\u9762&quot;</span><span class="token punctuation">,</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
   
          <span class="token punctuation">{</span>
            code<span class="token operator">:</span> <span class="token string">&quot;111&quot;</span><span class="token punctuation">,</span>
            label<span class="token operator">:</span> <span class="token string">&quot;111-\u70B8\u9E21&quot;</span><span class="token punctuation">,</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
        <span class="token punctuation">]</span><span class="token punctuation">,</span>
      <span class="token punctuation">}</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token punctuation">}</span><span class="token punctuation">;</span>
  <span class="token operator">&lt;</span><span class="token operator">/</span>script<span class="token operator">&gt;</span>
  </code></pre></div>`,1),e=[o];function c(u,l,k,r,i,d){return a(),s("div",null,e)}var f=n(p,[["render",c]]);export{g as __pageData,f as default};
  