vue实现的步骤条组件——2种方法

语言:vue
一、根据计算长度控制样式变化

  1. 样式如下:
    在这里插入图片描述
    2.代码:根据长度百分比计算样式
<template>
  <!-- 步骤条盒子 -->
  <div class="steps-box">
    <!-- 步骤条 -->
    <div
      class="Article-steps"
      :class="data.stepList.length <= activeIndex ? 'step-over' : ''"
    >
      <!-- 步骤条背景进度条 -->
      <div class="line">
        <span
          class="plan"
          :style="`width:${
     
            (activeIndex - 1) * (100 / (data.stepList.length - 1))
          }%`"
        ></span>
      </div>
      <!-- 每步部分 -->
      <span
        class="step"
        v-for="(i, index) in data.stepList"
        :key="index"
        :class="
          activeIndex == i.stepIndex || i.stepIndex <= activeIndex
            ? 'step-active'
            : 'step-start'
        "
      >
        <span
          class="step-num"
          :class="{ active: activeIndex + 1 === i.stepIndex }"
        >
          <span
            class="num"
            :class="{ active: activeIndex + 1 === i.stepIndex }"
            >{
   {
    i.stepIndex }}</span
          >
        </span>
        <p class="title" :class="{ active: activeIndex + 1 === i.stepIndex }">
          {
   {
    i.title }}
        </p>
      </span>
    </div>
  </div>
</template>
<script>
import {
    reactive, ref } from "vue";

export default {
   
  setup() {
   
    const activeIndex = ref(3);
    const data = reactive({
   
      //步骤条步数
      stepList: [
        
  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用uniapp + vue开发自定义相机插件,您需要以下步骤: 1. 创建一个uniapp项目。 2. 在项目的manifest.json文件中,添加拍照权限。 3. 在页面中引入uni-ui组件库,以便使用相机组件。 4. 创建一个拍照页面,将相机组件添加到页面中。 5. 创建一个拍照函数,用于触发拍照事件。 6. 在拍照函数中,使用uni-app提供的API调用相机。 7. 将拍摄的照片保存到本地,并显示在页面上。 以下是一些示例代码,可以帮助您开始编写自定义相机插件: 1. 在manifest.json文件中添加拍照权限: ``` { "name": "my-app", "permissions": { "camera": { "desc": "用于拍照" } } } ``` 2. 在页面中引入uni-ui组件库: ``` <template> <view> <camera :device-position="cameraPosition"></camera> <button @click="takePhoto">拍照</button> <image v-if="photo" :src="photo"></image> </view> </template> <script> import { Camera } from 'uni-ui'; export default { components: { Camera }, data() { return { cameraPosition: 'back', photo: '' } }, methods: { takePhoto() { uni.showLoading({ title: '正在拍照...' }); uni.createCameraContext().takePhoto({ quality: 'high', success: (res) => { this.photo = res.tempImagePath; }, complete: () => { uni.hideLoading(); } }); } } } </script> ``` 3. 在拍照函数中调用相机API: ``` takePhoto() { uni.showLoading({ title: '正在拍照...' }); uni.createCameraContext().takePhoto({ quality: 'high', success: (res) => { uni.saveImageToPhotosAlbum({ filePath: res.tempImagePath, success: () => { uni.showToast({ title: '保存成功!' }); } }); }, fail: (error) => { uni.showToast({ title: '拍照失败!' }); }, complete: () => { uni.hideLoading(); } }); } ``` 4. 将拍摄的照片保存到本地,并显示在页面上: ``` takePhoto() { uni.showLoading({ title: '正在拍照...' }); uni.createCameraContext().takePhoto({ quality: 'high', success: (res) => { this.photo = res.tempImagePath; }, complete: () => { uni.hideLoading(); } }); } ``` 这些示例代码可以帮助您开始编写自定义相机插件。请注意,这只是一个示例,您需要根据自己的需求进行修改和调整。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值