vue3步骤条带边框点击切换高亮

在这里插入图片描述
如果是div使用clip-path: polygon(0% 0%, 92% 0%, 100% 50%, 92% 100%, 0% 100%, 8% 50%);进行裁剪加边框没实现成功。目前这个使用svg完成带边框的。
形状可自行更改path 标签里的 :d=“[num != 1 ? ‘M 0 0 L 160 0 L 176 18 L 160 38 L 0 38 L 15.5 18 Z’ : ‘M 0,0 L 160,0 L 176,18 L 160,38 L 0,38 Z’]”

<!-- 进度条 -->
<template>
  <div class="stepsBox">
    <div class="stepsContent">
        <svg width="176" height="38" viewBox="0 0 176 38"  v-for="num in stepsDesc.length" :key="num" @click="onChange(num)">
                <path  :d="[num != 1 ? 'M 0 0 L 160 0 L 176 18 L 160 38 L 0 38 L 15.5 18 Z' : 'M 0,0 L 160,0 L 176,18 L 160,38 L 0,38 Z']" 
                        :fill="[letIndex == num ? '#AC8757' : '#fff' ]" :stroke="[letIndex == num ? '#AC8757' : nowIndex  == num ? '#AC8757' : '#999' ]" stroke-width="1"/>
                <text  x="50" y="24" font-family="Arial" font-size="14" :fill="[ nowIndex  == num && letIndex != num ? '#AC8757' : letIndex == num ? '#fff' : '#666' ]">③投资咨询</text>
        </svg>
    </div>


  </div>
</template>
<script setup>
import {
    reactive,
    ref
  } from 'vue'
const props = defineProps({
  stepsDesc: {
    type: [Array, Object]
  }
});
const letIndex = ref(2)
const nowIndex = ref(1) //代表当前进行那个步骤,进行边框文字颜色的改变
const onChange = (index) => {
        letIndex.value = index
    }
</script>


<style lang="scss" scoped>
.stepsBox {
    margin: 15px auto;
    height: 60px;
    position: relative;
    .stepsContent {
        display: flex;
        padding: 0 30px;
        align-items: center;
        
    }
}
</style>
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue 3中使用路由和TypeScript创建点击切换路由的功能,你可以按照以下步骤进行操作: 1. 首先,确保已经安装了vue-router和TypeScript相关的依赖包。你可以使用以下命令安装它们: ``` npm install vue-router@next npm install -D @types/vue-router ``` 2. 创建一个`router`文件夹,在其中创建一个`index.ts`文件来配置路由。在`index.ts`中,你需要导入Vuevue-router,然后创建一个新的路由实例。 ```typescript import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'; import Home from '../views/Home.vue'; import About from '../views/About.vue'; const routes: Array<RouteRecordRaw> = [ { path: '/', name: 'Home', component: Home, }, { path: '/about', name: 'About', component: About, }, ]; const router = createRouter({ history: createWebHistory(), routes, }); export default router; ``` 3. 在主入口文件(一般是`main.ts`)中,导入路由文件并将其挂载到Vue应用上。 ```typescript import { createApp } from 'vue'; import App from './App.vue'; import router from './router'; const app = createApp(App); app.use(router); app.mount('#app'); ``` 4. 在Vue组件中,你可以使用`<router-link>`组件来创建路由链接,使用`<router-view>`组件来显示路由组件。 ```html <template> <div> <router-link to="/">Home</router-link> <router-link to="/about">About</router-link> <router-view></router-view> </div> </template> ``` 这样,当你点击路由链接时,路由会自动切换到对应的页面组件。 希望这能帮助到你!如果有更多问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值