<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>html5和css3</title>
	<atom:link href="http://www.newlifeclan.com/html5/feed" rel="self" type="application/rss+xml" />
	<link>http://www.newlifeclan.com/html5</link>
	<description>记录前端html5和css3.0技术</description>
	<lastBuildDate>Fri, 29 Jul 2022 02:55:08 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.0.38</generator>
	<item>
		<title>videojs的vtt字幕Unsafe attempt to load URL错误</title>
		<link>http://www.newlifeclan.com/html5/archives/992</link>
		<comments>http://www.newlifeclan.com/html5/archives/992#comments</comments>
		<pubDate>Thu, 28 Jul 2022 08:06:25 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=992</guid>
		<description><![CDATA[video的track外挂vtt字幕，服务器和前端地址分离，所以域名不一致导致如下错误 报错： Unsafe  [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>video的track外挂vtt字幕，服务器和前端地址分离，所以域名不一致导致如下错误</p>
<p>报错：</p>
<p>Unsafe attempt to load URL &lt;URL&gt; from frame with URL &lt;URL&gt;. Domains, protocols and ports must match.<span id="more-992"></span></p>
<p>解决办法：</p>
<div>
<div>在视频标签上添加  &lt;video crossorigin=&#8217;anonymous&#8217;</div>
<div>如此处所述：<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/track" rel="noopener nofollow ugc">https ://developer.mozilla.org/en-US/docs/Web/HTML/Element/track</a></div>
<div>src轨道地址vtt文件，必须是一个有效而且要是相同来源，（重点）除非 track 元素的父元素具有 crossorigin 属性。</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/992/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Unity3d IIS部署报错</title>
		<link>http://www.newlifeclan.com/html5/archives/943</link>
		<comments>http://www.newlifeclan.com/html5/archives/943#comments</comments>
		<pubDate>Fri, 05 Nov 2021 05:52:22 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=943</guid>
		<description><![CDATA[Unity 中发布可以正常访问，但是发布到IIS就会出现错误提示 其实很简单我们让WebGL.linkerTa [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Unity 中发布可以正常访问，但是发布到IIS就会出现错误提示</p>
<p>其实很简单我们让WebGL.linkerTarget开启WebAssembly</p>
<p>File -&gt; Build Setting -&gt; Player Setting &#8211;&gt;Player 开启 Decompression Fallback</p>
<p><img class="alignnone size-full wp-image-944" src="http://www.newlifeclan.com/html5/wp-content/uploads/sites/3/2021/11/img_20211105134849.jpg" alt="img_20211105134849" width="637" height="498" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/943/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>`The value of the ‘Access-Control-Allow-Origin‘ header in the response must not be the wildcard</title>
		<link>http://www.newlifeclan.com/html5/archives/938</link>
		<comments>http://www.newlifeclan.com/html5/archives/938#comments</comments>
		<pubDate>Tue, 05 Oct 2021 10:29:18 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=938</guid>
		<description><![CDATA[详细错误信息 Access to XMLHttpRequest at &#8216;http://localh [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>详细错误信息 Access to XMLHttpRequest at &#8216;http://localhost:7894/Login&#8217; from origin &#8216;http://localhost:8080&#8242; has been blocked by CORS policy: Response to preflight request doesn&#8217;t pass access control check: The value of the &#8216;Access-Control-Allow-Origin&#8217; header in the response must not be the wildcard &#8216;*&#8217; when the request&#8217;s credentials mode is &#8216;include&#8217;. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.</p>
<hr />
<p>&nbsp;</p>
<p>前端可以删除</p>
<p>// axios.defaults.withCredentials = true</p>
<p>&nbsp;</p>
<p>或者后端可以加上</p>
<p>Access-Control-Allow-Credentials = true //允许携带验证信息</p>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/938/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Element implicitly has an &#8216;any&#8217; type because index expression is not of type &#8216;number&#8217;</title>
		<link>http://www.newlifeclan.com/html5/archives/928</link>
		<comments>http://www.newlifeclan.com/html5/archives/928#comments</comments>
		<pubDate>Tue, 05 Oct 2021 10:21:47 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=928</guid>
		<description><![CDATA[[crayon-69f39299e705d790161927/] 就是上面的代码报的错： 解决： [crayo [&#8230;]]]></description>
				<content:encoded><![CDATA[<p></p><pre class="crayon-plain-tag">for (x in browserPrefix) {
    if (el.style[x] !== undefined) {
    //           ^---- [TS Error]: Element has 'any' type b/c index expression is not of type 'number'
      return browserPrefix[x];
    }
  }</pre><p>就是上面的代码报的错：</p>
<p><strong>解决：</strong></p><pre class="crayon-plain-tag">for (x in browserPrefix) {
    if (el.style[x as any] !== undefined) {
      return browserPrefix[x];
    }
  }</pre><p>给个any类型就行</p>
<p>[x as any]</p>
<div id="gtx-trans"></div>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/928/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>svg 变换颜色</title>
		<link>http://www.newlifeclan.com/html5/archives/856</link>
		<comments>http://www.newlifeclan.com/html5/archives/856#comments</comments>
		<pubDate>Mon, 05 Jul 2021 09:43:37 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=856</guid>
		<description><![CDATA[openlayers中如何使用svg作为图标，并能够对其变换颜色。 [crayon-69f39299e8ab6 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>openlayers中如何使用svg作为图标，并能够对其变换颜色。<span id="more-856"></span></p><pre class="crayon-plain-tag">let point1_style = new ol.style.Style({//预测点
image: new ol.style.Icon({
            color: 'red',
            src: 'images/home-outline.svg',
            fill: new ol.style.Fill({
                   color: 'red',
            })
})</pre><p>如何变换颜色呢？或者说我定义的颜色？<br />
下面是我的svg全部内容：</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" standalone="no"?&gt;&lt;!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"&gt;&lt;svg t="1625461157551" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1077" xmlns:xlink="http://www.w3.org/1999/xlink" width="20" height="20"&gt;&lt;defs&gt;&lt;style type="text/css"&gt;&lt;/style&gt;&lt;/defs&gt;&lt;g id="831220218805300"&gt;&lt;path d="M514.4 112.2c5.2 0 10.3 1.8 14.3 5.2l321.4 309.2v462.9c0 12.3-10 22.2-22.3 22.2H662.3V743.9c0-26.9-10.5-52.3-29.6-71.3-19.1-19.1-44.4-29.5-71.4-29.5h-99.1c-27 0-52.3 10.6-71.3 29.7s-29.5 44.4-29.5 71.4v167.6H201c-8 0-13.3-4.1-15.8-6.6-2.4-2.4-6.5-7.7-6.5-15.8V422.7l321.2-305c4-3.5 9.2-5.5 14.5-5.5m0-50c-17.4 0-34.7 6.2-48.5 18.7L74 453.1c-14.7 13.5-15.7 36.4-2.2 51.1 7.1 7.8 16.9 11.7 26.6 11.7 8.5 0 17.1-3 23.9-9.1l6.2-5.9v388.4c0 39.9 32.3 72.4 72.2 72.4h210.5V744c0-28.1 22.7-50.9 50.9-51h99.1c28.1 0 50.9 22.8 50.9 50.9V961.7h215.4c39.9 0 72.3-32.4 72.3-72.3V505.7c7.7 7 16.9 10.3 25.9 10.3 9.8 0 19.4-4 26.3-11.8 13.4-14.8 12.2-37.7-2.6-51.1L562.9 81c-13.7-12.5-31.1-18.8-48.5-18.8z" p-id="1078" style="fill:#ffffff;"  &gt;&lt;/path&gt;&lt;/g&gt;&lt;/svg&gt;</pre><p>核心重点：我们的color替换的就是</p>
<p>path里一定要写的</p>
<div>
<div>style=&#8221;fill:#ffffff;&#8221;</div>
<div>我们外界定义的color就会替换fill中的颜色</div>
<div></div>
<div>注意：不要写成fill=”#ffffff“ 这样无法替换</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/856/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vue数组更新不渲染页面</title>
		<link>http://www.newlifeclan.com/html5/archives/839</link>
		<comments>http://www.newlifeclan.com/html5/archives/839#comments</comments>
		<pubDate>Mon, 31 May 2021 02:59:54 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=839</guid>
		<description><![CDATA[原因： 由于 JavaScript 的限制，Vue 不能检测以下变动的数组： 当你利用索引直接设置一个项时，例 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p><strong>原因：</strong></p>
<p>由于 JavaScript 的限制，Vue 不能检测以下变动的数组：</p>
<ol>
<li>当你利用索引直接设置一个项时，例如：<code>vm.items[indexOfItem] = newValue</code></li>
<li>当你修改数组的长度时，例如：<code>vm.items.length = newLength</code></li>
</ol>
<p><span id="more-839"></span></p>
<p><strong>解决方案：</strong></p>
<p>通过splice()方法，删除某个元素后，再添加一个元素，达到“赋值”的效果：</p>
<p>vm.items.splice(index, 1, newElement);</p>
<p>Vue可以监听数组的splice、push、unshift等方法调用正确更新View。</p>
<p>this.$set(this.arr,&#8221;key&#8221;, 111)</p>
<p>Vue.set( target , key , value)<strong><br />
</strong></p>
<ul>
<ul>
<li>target: 要更改的数据源（可以是一个对象或者数组）</li>
<li>key 要更改的具体数据 （索引）</li>
<li>value 重新赋的值</li>
</ul>
</ul>
<p>或者</p>
<p>this.$forceUpdate()    //强制刷新</p>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/839/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>文件下载js-file-download</title>
		<link>http://www.newlifeclan.com/html5/archives/835</link>
		<comments>http://www.newlifeclan.com/html5/archives/835#comments</comments>
		<pubDate>Fri, 21 May 2021 08:24:44 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=835</guid>
		<description><![CDATA[我这里是一个pdf文件，在页面按钮点击后希望实现文件下载功能，而不是在页面打开pdf预览 有一个插件很好htt [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>我这里是一个pdf文件，在页面按钮点击后希望实现文件下载功能，而不是在页面打开pdf预览</p>
<p>有一个插件很好https://github.com/kennethjiang/js-file-download<span id="more-835"></span></p>
<p>我们在vue-cli的依赖中找到它，并安装</p>
<p>在src/utils/filedownload.js</p><pre class="crayon-plain-tag">import axios from 'axios'
import fileDownload from 'js-file-download';

export function download(url, filename) {
    //因为跨域，去掉域名，使用vue.config.js代理转发
    url = '/' + url.split('/').slice(3).join('/')
    axios.get('/api/'+url, {
    responseType: 'blob',
    withCredentials: true,
    crossDomain: true,
  }).then(res =&gt; {
    fileDownload(res.data, filename);
  });
}</pre><p>如何使用呢？</p><pre class="crayon-plain-tag">download(fileurl,filename+'.pdf');</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/835/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vue 全局过滤器</title>
		<link>http://www.newlifeclan.com/html5/archives/832</link>
		<comments>http://www.newlifeclan.com/html5/archives/832#comments</comments>
		<pubDate>Mon, 17 May 2021 07:46:19 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=832</guid>
		<description><![CDATA[我是用vue-cli创建的项目 首先我们创建src/filters/index.vue，用于存放filter方 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>我是用vue-cli创建的项目</p>
<p>首先我们创建src/filters/index.vue，用于存放filter方法<span id="more-832"></span></p><pre class="crayon-plain-tag">/**
 * Convert audio tags to img in html5 and play
 * @param {含有audio的html内容} htmlstring 
 * @returns 
 */
export function changehtmlaudiotoimgplay(htmlstring){
  let reg = new RegExp(
    '&lt;audio controls="controls" controlslist="nodownload" src="(.*?)"&gt;&amp;nbsp;&lt;/audio&gt;',
    'g'
  )
  htmlstring = htmlstring.replace(
    reg,
    '&lt;img  style="width:25px;height:25px;vertical-align: middle;" src="' +
      require('@/' + '/assets/hornpause.jpg') +
      '" class="na_htmlplayaudio" data-audio-url="$1" /&gt;'
  )
  return htmlstring
}</pre><p>下一步注册成全局可以使用的filter</p><pre class="crayon-plain-tag">import Vue from 'vue'
import App from './App.vue'
import router from './router'
......

// global filters
import * as filters from './filters' 
// register global utility filters
Object.keys(filters).forEach(key =&gt; {
  Vue.filter(key, filters[key])
})


Vue.config.productionTip = false

new Vue({
  router,
  i18n,
  store,
  render: h =&gt; h(App)
}).$mount('#app')</pre><p>&nbsp;</p>
<p>使用</p><pre class="crayon-plain-tag">{{ HtmlData | changehtmlaudiotoimgplay }}
&lt;!--或者--&gt;
v-html="$options.filters.changehtmlaudiotoimgplay(HtmlData)"</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/832/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vue中v-html的内容替换和事件绑定</title>
		<link>http://www.newlifeclan.com/html5/archives/825</link>
		<comments>http://www.newlifeclan.com/html5/archives/825#comments</comments>
		<pubDate>Tue, 04 May 2021 12:21:03 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=825</guid>
		<description><![CDATA[我们现在要处理一种情况，后台输出了一些html数据，但是希望将audio默认的标签，换成一个喇叭图片，类似百度 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>我们现在要处理一种情况，后台输出了一些html数据，但是希望将audio默认的标签，换成一个喇叭图片，类似百度翻译的发音图标。并能够播放音频</p>
<p><img class="alignnone size-full wp-image-826" src="http://www.newlifeclan.com/html5/wp-content/uploads/sites/3/2021/05/20210504200101.jpg" alt="20210504200101" width="249" height="109" /><span id="more-825"></span></p>
<p><strong>替换audio标签为img</strong></p>
<p>因为数据从后端api获取，所以我们获取数据后，用正则先替换audio为img并记录音频地址</p>
<p>template模板</p><pre class="crayon-plain-tag">&lt;div 
     @click="htmlaudioplayen()" 
     v-html="htmlchangedaudio(outhtml)"
 &gt;&lt;/div&gt;
 &lt;audio
                style="display:none"
                ref="htmlaudio"
                controls
                controlsList="nodownload"
                @ended="htmlaudioenden"
              &gt;&lt;/audio&gt;</pre><p>&nbsp;</p>
<p>script方法：</p><pre class="crayon-plain-tag">methods: {
    //替换html内容
    htmlchangedaudio(outhtml) {
      let reg = new RegExp(
        '&lt;audio controls="controls" controlslist="nodownload" src="(.*?)"&gt;&amp;nbsp;&lt;/audio&gt;',
        'g'
      )
      outhtml = outhtml.replace(
        reg,
        '&lt;img  style="width:25px;height:25px;vertical-align: middle;" src="' +
          require('@/' + '/assets/hornpause.jpg') +
          '" class="na_htmlplayaudio" data-audio-url="$1" /&gt;'
      )
      return outhtml
    },</pre><p>我们将audio的src音频地址，放到了img的data-audio-url中，以便后面点击事件可以获取到播放的资源。</p>
<p>你会看到我们的div下面还有一个隐藏的audio文件，后面我们会用到它。</p>
<p>&nbsp;</p>
<p><strong>事件绑定</strong></p>
<p>如何让小喇叭图片可以播放呢？</p><pre class="crayon-plain-tag">//点击图标发声
    htmlaudioplayen() {
      var event = window.event
      window.console.log(event)
      if (
        event.target.tagName === 'IMG' &amp;&amp;
        event.target.className === 'na_htmlplayaudio'
      ) {
        // 获取触发事件对象的属性
       var htmlaudio=  this.$refs.htmlaudio;
       htmlaudio.src = event.target.dataset.audioUrl
       htmlaudio.play()
      }
    },</pre><p>其实很简单，我们获取到event，拿到此img之前绑定的data-audio-url，然后赋值给之前埋好的audio的src，让这个隐藏的audio播放即可。</p>
<p>&nbsp;</p>
<p><strong>img喇叭状态改变</strong></p>
<p>现在喇叭在播放时不会动，我们希望播放时喇叭能够有播放动画。咋办，我们找来了一张gif图，在播放时切换它。并在播放停止后，切换回不同的小喇叭。</p>
<p>要实现这样的效果我们需要加一些代码</p><pre class="crayon-plain-tag">//点击图标发声
    htmlaudioplayen() {
      var event = window.event
      this.htmlcurrentaudio = event
      window.console.log(event)
      if (
        event.target.tagName === 'IMG' &amp;&amp;
        event.target.className === 'na_htmlplayaudio'
      ) {
        //切换图标
        event.target.src = require('@/' + '/assets/horn.gif')
        // 获取触发事件对象的属性
       var htmlaudio=  this.$refs.htmlaudio;
       htmlaudio.src = event.target.dataset.audioUrl
       htmlaudio.play()
      }
    },
    //播放停止还原图标
    htmlaudioenden(){
        this.htmlcurrentaudio.target.src = require('@/' + '/assets/hornpause.jpg')
    },</pre><p>完活！还有优化空间，后续你们自己发挥把，拜拜</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/825/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vue国际化多语言</title>
		<link>http://www.newlifeclan.com/html5/archives/817</link>
		<comments>http://www.newlifeclan.com/html5/archives/817#comments</comments>
		<pubDate>Sun, 18 Apr 2021 11:19:25 +0000</pubDate>
		<dc:creator><![CDATA[napoleon]]></dc:creator>
				<category><![CDATA[未分类]]></category>

		<guid isPermaLink="false">http://www.newlifeclan.com/html5/?p=817</guid>
		<description><![CDATA[使用的vue2 + element ui + i18n来实现的国际化 安装i18n 直接使用的vue-cli4 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>使用的vue2 + element ui + i18n来实现的国际化<span id="more-817"></span></p>
<h2>安装i18n</h2>
<p>直接使用的vue-cli4界面的运行依赖中，来安装的i18n</p>
<p><img class="alignnone size-full wp-image-818" src="http://www.newlifeclan.com/html5/wp-content/uploads/sites/3/2021/04/20210418190256.jpg" alt="20210418190256" width="815" height="87" /></p>
<h2>创建翻译的配置文件</h2>
<p>把他放到assets目录下即可</p>
<p><img class="alignnone size-large wp-image-819" src="http://www.newlifeclan.com/html5/wp-content/uploads/sites/3/2021/04/2021041815185284-1024x256.png" alt="2021041815185284" width="780" height="195" /></p>
<h2>使用配置文件并和element国际化兼容</h2>
<p>在src下新建i18n目录，创建一个 index.js；路径src\i18n\index.js</p><pre class="crayon-plain-tag">import Vue from 'vue'
import VueI18n from 'vue-i18n'

import ElementLocale from 'element-ui/lib/locale'
import enLocale from 'element-ui/lib/locale/lang/en'
import zhLocale from 'element-ui/lib/locale/lang/zh-CN'

import langZh from "@/assets/languages/zh.js"
import langEN from "@/assets/languages/en.js"

Vue.use(VueI18n)
 
const i18n = new VueI18n({
  locale: 'zh',
  messages: {
    'zh': {...langZh,...zhLocale},
    'en': {...langEN,...enLocale}
  }
})
ElementLocale.i18n((key, value) =&gt; i18n.t(key, value))

export default i18n</pre><p></p>
<h2> 引用</h2>
<p>在main.js中引用</p><pre class="crayon-plain-tag">import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
import './icons' // icon

import i18n from './i18n/index' //新加-国际化

Vue.config.productionTip = false

new Vue({
  router,
  i18n, //新加
  store,
  render: h =&gt; h(App)
}).$mount('#app')</pre><p></p>
<h2> 如何使用</h2>
<p>模板中我们使用$t</p><pre class="crayon-plain-tag">{{$t('common.icao_service')}}

//script中使用方式
this.$t('common.icao_service')</pre><p>&nbsp;</p>
<h2>语言如何切换</h2>
<p></p><pre class="crayon-plain-tag">&lt;el-button @click="switchLang"&gt;

switchLang() {
      console.log(this.$i18n.locale);
      if (this.$i18n.locale === "zh") {
        this.$i18n.locale = "en";
      } else {
        this.$i18n.locale = "zh";
      }
      // this.$i18n.locale = val; //此处val为 zh 或者 en
    },</pre><p>&nbsp;</p>
<p>最终效果</p>
<p><img class="alignnone size-full wp-image-820" src="http://www.newlifeclan.com/html5/wp-content/uploads/sites/3/2021/04/20210418152343727.png" alt="20210418152343727" width="604" height="137" /></p>
<p><img class="alignnone size-full wp-image-821" src="http://www.newlifeclan.com/html5/wp-content/uploads/sites/3/2021/04/20210418152323467.png" alt="20210418152323467" width="600" height="154" /></p>
<p>【转载文章】https://blog.csdn.net/qq_45949366/article/details/108535247</p>
]]></content:encoded>
			<wfw:commentRss>http://www.newlifeclan.com/html5/archives/817/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
