1
jhzh
2026-05-22 ef52095f5e9f0a9fe2da779bb1573947d77d75b6
src/components/fx-kline/index.vue
@@ -1,5 +1,5 @@
<template>
  <div id="kline" class="boxDisplay" :style="{ height: `${props.height || defaultH}px`, position: 'relative' }"
  <div :id="props.chartId" class="boxDisplay" :style="{ height: `${props.height || defaultH}px`, position: 'relative' }"
    v-if="defaultH">
  </div>
  <ul class="flex px-4 py-4 box-border justify-between indicator-box" v-if="showBottom"
@@ -49,6 +49,10 @@
const props = defineProps({
  symbol: {
    type: String
  },
  chartId: {
    type: String,
    default: 'kline'
  },
  height: {
    type: Number
@@ -137,7 +141,7 @@
}
const initData = async () => {
  chart = init('kline', config);
  chart = init(props.chartId, config);
  chart.setOffsetRightSpace(15)
  chart.setDataSpace(10)
  if (props.isShowsolid) {
@@ -172,30 +176,24 @@
    length = 2
  }
  chart.setPriceVolumePrecision(length, 2)
  localStorage.setItem('kline', JSON.stringify(data.value))
  localStorage.setItem(`kline_${props.chartId}`, JSON.stringify(data.value))
  nextTick(() => {
    chart.applyNewData(data.value);
  })
}
const initData1 = async () => {
  chart = init('kline', config);
  chart = init(props.chartId, config);
  chart.setOffsetRightSpace(15)
  chart.setDataSpace(10)
  let length = 2
  data.value = JSON.parse(localStorage.getItem('kline'))
  data.value = JSON.parse(localStorage.getItem(`kline_${props.chartId}`))
  try {
    length = data.value[data.value.length - 1].decimals
    length = data.value && data.value.length ? data.value[data.value.length - 1].decimals : 2
  } catch (e) {
    length = 2
  }
  chart.setPriceVolumePrecision(length, 2)
  // if (props.type === 'candle_solid') {
  //     chart.createTechnicalIndicator('MA', false, { id: 'candle_pane' });
  //     paneId.value = chart.createTechnicalIndicator('VOL');
  // }
  // this.fetchData()
  chart.setStyleOptions({
    candle: {
      type: props.chartType
@@ -204,10 +202,8 @@
  if (!quotesStore.stage) {
    quotesStore[SET_STAGE]({ stage: '1min', seconds: 1 * 60 * 1000 })
  }
  // console.log(data.value)
  nextTick(() => {
    chart.applyNewData(data.value);
    if (data.value && data.value.length) chart.applyNewData(data.value);
  })
}
const choiceType = (type) => { // 选择副线