实现动态切换组件
-
使用
<component is="组件名"></component>
component为内置组件,使用 is = “组件名”,就会自动去找匹配的组件(即is的值写的是哪个组件,component就代表的是哪个组件)想要改变挂载的组件,只需要修改is对应的值即可
html
<template>
<div :style="{border: '1px solid red'}">
<button @click="pButton1(0)">Path1</button>
<button @click="pButton2(1)">Path2</button>
<keep-alive >
<component :is=