国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c

這篇具有很好參考價(jià)值的文章主要介紹了[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

報(bào)錯(cuò)翻譯:避免直接更改一個(gè)prop,因?yàn)槊慨?dāng)父組件重新渲染時(shí),該值都會(huì)被覆蓋。相反,應(yīng)使用基于prop值的數(shù)據(jù)或計(jì)算屬性。正在更改的prop:“activeId”
解決辦法,使用基于prop的值,即把名為activeId的prop的值放在另一個(gè)變量中,對那個(gè)變量進(jìn)行修改,不修改activeId。
1、實(shí)現(xiàn)功能
avoid mutating a prop directly since the value will be overwritten whenever,前端報(bào)錯(cuò),vue.js,javascript,前端
有三個(gè)頁面,共用一個(gè)頂部導(dǎo)航,頂部導(dǎo)航封裝為一個(gè)組件,原始代碼如下,切換時(shí)報(bào)錯(cuò):
2、組件代碼
activeId為傳遞的值,用于存放某一頁導(dǎo)航選中的索引記錄。

<template>
	<div class="headMiddle flexCenter">
		<div class="widthStyle">
			<div class="flexBetween">
				<div v-for="(item,index) in dataArray" :key="index" @click="handleChose(index)"
					:class="activeId==index?'activeItemStyle':'itemStyle'">
					<div class="jbStle"></div>
					<div class="bordStatistic">
						<div class="nameStyle">
							{{item.name}}
						</div>
					</div>
					<div class="jbStle"></div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		name: "TopBar",
		components: {},
		props: {
			activeId: {
				required: true,
				type: Number
			},
		},
		data() {
			return {
				dataArray: [{
						name: '首頁',
						path: 'home',

					},
					{
						name: '農(nóng)機(jī)管理',
						path: 'machineList',
					},
					{
						name: '服務(wù)管理',
						path: 'serviceManage',
					},

				],
			}
		},
		computed: {

		},
		mounted() {

		},
		methods: {
			handleChose(index) {
				this.activeId = index;
				this.$router.push(this.dataArray[index].path)
			},
		}
	};
</script>
<style lang="scss" scoped>
	.headMiddle {
		position: absolute;
		top: 12% !important;
		left: 0px;
		right: 0px;
		z-index: 2;

		.widthStyle {
			width: 40%;
			min-width: 556px;
		}

		.activeItemStyle,
		.itemStyle {
			cursor: pointer;

			.jbStle {
				width: 76px;
				height: 1px;
			}

			.bordStatistic {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 76px;
				height: 32px;
				background: rgba(7, 53, 58, 0.8);

				.nameStyle {
					font-size: 13px;
					font-weight: 500;
					color: #FEFFFF;
				}
			}
		}

		.activeItemStyle {
			.jbStle {
				background-color: rgba($color: #61FFF6, $alpha: 1);
			}

			.bordStatistic {
				background: rgba(#61FFF6, 0.2);
			}

			.nameStyle {
				text-shadow: 0px 2px 1px rgba(0, 1, 1, 0.63);
			}
		}

		.itemStyle {
			.jbStle {
				background-color: rgba($color: #61FFF6, $alpha: 0.4);
			}
		}
	}
</style>

3、調(diào)用組件頁面代碼
該頁面為農(nóng)機(jī)管理,activeId等于1。

<TopBar :activeId='1'></TopBar>

avoid mutating a prop directly since the value will be overwritten whenever,前端報(bào)錯(cuò),vue.js,javascript,前端

————————————————————————————————————
上述代碼報(bào)錯(cuò),以下是修改。
4、修改。調(diào)用組件頁面不用更改,僅修改組件。聲明一個(gè)新的變量activeTemp,對它進(jìn)行修改。
avoid mutating a prop directly since the value will be overwritten whenever,前端報(bào)錯(cuò),vue.js,javascript,前端
avoid mutating a prop directly since the value will be overwritten whenever,前端報(bào)錯(cuò),vue.js,javascript,前端
avoid mutating a prop directly since the value will be overwritten whenever,前端報(bào)錯(cuò),vue.js,javascript,前端文章來源地址http://www.zghlxwxcb.cn/news/detail-774980.html

<template>
	<div class="headMiddle flexCenter">
		<div class="widthStyle">
			<div class="flexBetween">
				<div v-for="(item,index) in dataArray" :key="index" @click="handleChose(index)"
					:class="activeTemp==index?'activeItemStyle':'itemStyle'">
					<div class="jbStle"></div>
					<div class="bordStatistic">
						<div class="nameStyle">
							{{item.name}}
						</div>
					</div>
					<div class="jbStle"></div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		name: "TopBar",
		components: {},
		props: {
			activeId: {
				required: true,
				type: Number
			},
		},
		data() {
			return {
				activeTemp:this.activeId,
				dataArray: [{
						name: '首頁',
						path: 'home',

					},
					{
						name: '農(nóng)機(jī)管理',
						path: 'machineList',
					},
					{
						name: '服務(wù)管理',
						path: 'serviceManage',
					},
				],
			}
		},
		computed: {

		},
		mounted() {

		},
		methods: {
			handleChose(index) {
				this.activeTemp = index;
				this.$router.push(this.dataArray[index].path)
			},
		}
	};
</script>
<style lang="scss" scoped>
	.headMiddle {
		position: absolute;
		top: 12% !important;
		left: 0px;
		right: 0px;
		z-index: 2;

		.widthStyle {
			width: 40%;
			min-width: 556px;
		}

		.activeItemStyle,
		.itemStyle {
			cursor: pointer;

			.jbStle {
				width: 76px;
				height: 1px;
			}

			.bordStatistic {
				display: flex;
				align-items: center;
				justify-content: center;
				width: 76px;
				height: 32px;
				background: rgba(7, 53, 58, 0.8);

				.nameStyle {
					font-size: 13px;
					font-weight: 500;
					color: #FEFFFF;
				}
			}
		}

		.activeItemStyle {
			.jbStle {
				background-color: rgba($color: #61FFF6, $alpha: 1);
			}

			.bordStatistic {
				background: rgba(#61FFF6, 0.2);
			}

			.nameStyle {
				text-shadow: 0px 2px 1px rgba(0, 1, 1, 0.63);
			}
		}

		.itemStyle {
			.jbStle {
				background-color: rgba($color: #61FFF6, $alpha: 0.4);
			}
		}
	}
</style>

到了這里,關(guān)于[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent c的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 報(bào)錯(cuò)-warning: in the working copy of ‘xxx.vue‘, LF will be replaced by CRLF the next time Git touc

    報(bào)錯(cuò)-warning: in the working copy of ‘xxx.vue‘, LF will be replaced by CRLF the next time Git touc

    問題:在進(jìn)行 git add時(shí),出現(xiàn)?報(bào)錯(cuò):warning: in the working copy of \\\'src/xxx.vue\\\', LF will be replaced by CRLF the next time Git touches it 翻譯:警告:在 \\\'src/xxx.vue\\\' 的工作副本中,下次 Git 遇到 LF 時(shí),LF 將被 CRLF 替換。 知識(shí)點(diǎn): CR為回車符,LF為換行符。Windows結(jié)束一行用CRLF,Mac和Linux用LF。 co

    2024年02月08日
    瀏覽(32)
  • warning: in the working copy of ‘App.vue‘, LF will be replaced by CRLF the next time Git touches it

    warning: in the working copy of ‘App.vue‘, LF will be replaced by CRLF the next time Git touches it

    git add . 一大串的warning warning: in the working copy of \\\'App.vue\\\', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of \\\'pages.json\\\', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of \\\'pages/cart/cart.vue\\\', LF will be replaced by CRLF the next time Git touches it warning: in the

    2024年02月14日
    瀏覽(24)
  • nginx : [warn] the “ssl“ directive is deprecated, use the “l(fā)isten ... ssl“ directive instead 解決

    nginx : [warn] the “ssl“ directive is deprecated, use the “l(fā)isten ... ssl“ directive instead 解決

    配置nginx 加載 證書,卸載SSL 啟動(dòng)時(shí)告警 nginx 報(bào)錯(cuò) : [warn] the \\\"ssl\\\" directive is deprecated, use the \\\"listen ... ssl\\\" directive instead: 錯(cuò)誤配置 nginx版本在1.15.x版本之后的,ssl on; 要去掉,listen 443; 改為 listen 443 ssl 調(diào)整后配置文件

    2024年02月11日
    瀏覽(21)
  • 【warning】UserWarning: The parameter ‘pretrained‘ is deprecated since 0.13 and may be removed

    【warning】UserWarning: The parameter ‘pretrained‘ is deprecated since 0.13 and may be removed

    報(bào)錯(cuò)內(nèi)容: 翻譯一下,就是參數(shù)列表中的pretrained在新版本中被棄了,要使用weights這個(gè)參數(shù)。然后教你用新的參數(shù)。 就按照watning里寫的把models.resnet101()后面的內(nèi)容重新設(shè)置就好。 第一種:weights = models.ResNet101_Weights.DEFAULT 輸出結(jié)果:? 第二種:weights = models.ResNet101_Weights.IMA

    2024年02月13日
    瀏覽(20)
  • nginx: [warn] the “ssl“ directive is deprecated, use the “l(fā)isten ... ssl“ directive instead in /

    原因: nginx在1.15.x版本之后不再使用 ssl on; 解決方法: ssl on; 要去掉,將 listen 443; 改為 listen 443 ssl; 原配置文件: worker_processes ?1; events { ? ? worker_connections ?1024; } http { ? ? include ? ? ? mime.types; ? ? default_type ?application/octet-stream; ? ? sendfile ? ? ? ?on; ? ? keepalive_timeout ?

    2024年02月04日
    瀏覽(25)
  • [Vue warn]: Avoid adding reactive properties to a Vue instance or its root $data at runtime - declar

    [Vue warn]: Avoid adding reactive properties to a Vue instance or its root $data at runtime - declar

    報(bào)錯(cuò)詳情圖: [Vue warn]: Avoid adding reactive properties to a Vue instance or its root $data at runtime - declare it upfront in the data option. 大概意思就是說?避免在運(yùn)行時(shí)向Vue實(shí)例或其根$data添加反應(yīng)性屬性-在數(shù)據(jù)選項(xiàng)中預(yù)先聲明它。 他讓我們在$data添加屬性,我們就進(jìn)行添加 可以先在按鈕里面定

    2024年02月13日
    瀏覽(13)
  • warning: in the working copy of ‘...‘, LF will be replaced by CRLF the next time Git touche

    執(zhí)行g(shù)it add .的時(shí)候出現(xiàn)的警告 解釋: CR/LF是不同操作系統(tǒng)上使用的換行符: CR(CarriageReturn回車 \\\'r\\\' ):回到一行的開頭,ASCII代碼是13 LF(LineFeed換行\(zhòng)\\' n\\\' ):另起一行,ASCII代碼是10 應(yīng)用情況: Dos 和 Windows 平臺(tái): 使用回車(CR)和換行(LF)兩個(gè)字符來結(jié)束一行,回車+換行

    2024年02月03日
    瀏覽(27)
  • warning: React does not recognize the xxx prop on a DOM element

    warning: React does not recognize the xxx prop on a DOM element Warning: React does not recognize the disableValue prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase disablevalue instead. If you accidentally passed it from a parent component, remove it from the DOM element 這是React不能識(shí)別

    2024年02月04日
    瀏覽(24)
  • 【Git】warning: in the working copy of ‘...‘, LF will be replaced by CRLF the next time Git touche

    執(zhí)行g(shù)it add .的時(shí)候出現(xiàn)的警告 解釋: CR/LF是不同操作系統(tǒng)上使用的換行符: CR(CarriageReturn回車 \\\'r\\\' ):回到一行的開頭,ASCII代碼是13 LF(LineFeed換行\(zhòng)\\' n\\\' ):另起一行,ASCII代碼是10 應(yīng)用情況: Dos 和 Windows 平臺(tái): 使用回車(CR)和換行(LF)兩個(gè)字符來結(jié)束一行,回車+換行

    2024年01月17日
    瀏覽(30)
  • 出現(xiàn)警告warning: in the working copy of ‘gitignore‘, LF will be replaced by CRLF the next time Git解決辦法

    git上傳項(xiàng)目出現(xiàn)警告warning: in the working copy of ‘gitignore’, LF will be replaced by CRLF the next time Git解決 提示:這個(gè)警告是由于 Git 檢測到在你的 gitignore 文件中使用的換行符 (line endings)是 LF(Unix 風(fēng)格)而非 CRLF (Windows 風(fēng)格)導(dǎo)致的。Git 會(huì)自動(dòng)將 LF 換為 CRLF 以符合你的操作系統(tǒng)的標(biāo)準(zhǔn)。

    2024年02月05日
    瀏覽(20)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包