在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答
離觴 回答

之前提問(wèn)并沒(méi)有指出是什么所謂同源事件 故而現(xiàn)在更新一波


正文開(kāi)始

其實(shí)也沒(méi)有什么難度,看了你的demo,無(wú)非是一些事件注冊(cè),好消息是我剛才順手寫了個(gè)vue-highchart里使用的例子,先放效果給你看吧

clipboard.png

其實(shí),最重要的是你忘記框架或者庫(kù)的存在,一切從js的層面去看它
以下是你評(píng)論里貼的例子的截圖

clipboard.png
可以看到就是獲取自身chart對(duì)象以及dom 然后得到其它c(diǎn)hart對(duì)象以及dom 然后開(kāi)始事件注冊(cè)
所以vue里面我們也這樣做不就好了?

我的代碼(關(guān)鍵步驟里面有注釋)

<template>
    <div>
        <highcharts style="height:200px;width:500px;" :options="createOption(chartData.chart1)" ref="c1"></highcharts>
        <highcharts style="height:200px;width:500px;" :options="createOption(chartData.chart2)" ref="c2"></highcharts>
        <highcharts style="height:200px;width:500px;" :options="createOption(chartData.chart3)" ref="c3"></highcharts>
    </div>
</template>

<script>
import { offset } from "@/js/utils";

export default {
    name: "test",
    data() {
        return {
            chartData: {
                chart1: [["1月", 10], ["2月", 12], ["3月", 22]],
                chart2: [["1月", 44], ["2月", 30], ["3月", 22]],
                chart3: [["1月", 10], ["2月", 30], ["3月", 8]],
            },
        };
    },
    methods: {
        createOption(data) {
            return {
                series: [{ data }],
            };
        },
    },
    mounted() {
        const { c1, c2, c3 } = this.$refs;
        const chart1 = c1.chart;
        const chart2 = c2.chart;
        const chart3 = c3.chart;
        // 你看chart對(duì)象是不是得到了
        const allChart = [chart1, chart2, chart3];
        // 定義一個(gè)獲取其它兄弟表集合的方法
        allChart.getOther = function(one) {
            return allChart.filter(c => c !== one);
        };
        // 循環(huán)進(jìn)行事件綁定
        allChart.forEach(chart => {
            // 你看自身chart的dom是不是得到了
            const container = chart.container;
            if (container instanceof Element) {
                container.addEventListener("mousemove", function(e) {
                    var sourceXAxis = chart.xAxis[0];
                    var extremes = sourceXAxis.getExtremes();
                    var targetChartContainerList = allChart.getOther(chart);
                    targetChartContainerList.forEach((ct, index) => {
                        var targetChart = ct;
                        var targetDom = ct.container;
                        var sourceOffset = offset(container);
                        var targetOffset = offset(targetDom);
                        var targetE = {};
                        for (var i in e) {
                            targetE[i] = e[i];
                        }
                        targetE.pageX =
                            e.pageX + targetOffset.left - sourceOffset.left;
                        targetE.pageY =
                            e.pageY + targetOffset.top - sourceOffset.top;
                        var targetEl =
                            targetDom.querySelector(
                                "rect.highcharts-background"
                            ) ||
                            targetDom.querySelector("path.highcharts-tracker");

                        targetE.target = targetE.srcElement = targetE.fromElement = targetE.toElement = targetEl;
                        targetE.delegateTarget = targetE.currentTarget = targetDom;
                        targetE.originalEvent = targetE;
                        if (targetChart && targetChart.pointer) {
                            targetChart.pointer.onContainerMouseMove(targetE);
                        }
                        if (targetChart && targetChart.scroller) {
                            targetChart.scroller.mouseMoveHandler(targetE);
                        }

                        if (
                            chart.mouseIsDown == "mouseup" ||
                            chart.mouseIsDown == "mousedown"
                        ) {
                            if (targetChart && targetChart.xAxis[0]) {
                                var targetXAxis = targetChart.xAxis[0];
                                targetXAxis.setExtremes(
                                    extremes.min,
                                    extremes.max
                                );
                            }
                        }
                    });
                    return false;
                });
            }
        });
    },
};
</script>

你看看事件注冊(cè)部分是不是和你的那個(gè)代碼很像,沒(méi)錯(cuò),我就是照著抄的。

offset是啥?

至于offset方法是啥?因?yàn)槲彝耆灰蕾囉趈query,所以自己實(shí)現(xiàn)了一個(gè)offset方法,基本也是照著jquery源碼抄著改的
也可以給你看一下offset的代碼

// offset: borrow ideas from the implement of offset in jQuery.fn.extend
export const offset = elem => {
    /* jshint eqeqeq: false */
    const isWindow = obj => obj != null && obj == obj.window;
    const getWindow = ele =>
        isWindow(ele)
            ? ele
            : ele.nodeType === 9 ? ele.defaultView || ele.parentWindow : false;

    let docElem,
        win,
        box = { top: 0, left: 0 },
        doc = elem && elem.ownerDocument;

    if (!doc) {
        return;
    }
    docElem = doc.documentElement;
    // Make sure it's not a disconnected DOM node
    if (!docElem.contains(elem)) {
        return box;
    }
    // If we don't have gBCR, just use 0,0 rather than error
    // BlackBerry 5, iOS 3 (original iPhone)
    if (typeof elem.getBoundingClientRect === "function") {
        box = elem.getBoundingClientRect();
    }
    win = getWindow(doc);
    return {
        top:
            box.top +
            (win.pageYOffset || docElem.scrollTop) -
            (docElem.clientTop || 0),
        left:
            box.left +
            (win.pageXOffset || docElem.scrollLeft) -
            (docElem.clientLeft || 0),
    };
};

其它注意事項(xiàng)

哦對(duì)了,我只抄了mousemove部分,其它部分你自己對(duì)著慢慢抄.
實(shí)際使用的時(shí)候,addEventListener里的function最好不要匿名,這樣方面組件beforeDestory的時(shí)候可以removeEventListener取消監(jiān)聽(tīng)

心夠野 回答

先排除是不是你代碼里面有這么個(gè)img標(biāo)簽

忠妾 回答

注釋說(shuō)了在第一次使用的時(shí)候才會(huì)初始化

  /**
     * The table, initialized on first use, and resized as
     * necessary. When allocated, length is always a power of two.
     * (We also tolerate length zero in some operations to allow
     * bootstrapping mechanics that are currently not needed.)
     */
    transient Node<K,V>[] table;

初始化代碼在 final Node<K,V>[] resize() 方法里面,


     Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap];
     table指向這個(gè)newTab
未命名 回答

md5 不是加密 彩虹表破解
前端通過(guò)一定手段把處理過(guò)的密碼傳到后端
后端用一樣的手段將數(shù)據(jù)庫(kù)的密碼處理 然后對(duì)比是否一樣

未命名 回答

你需要好好看看這個(gè)函數(shù)的作用了 array_multisort

<?php
$data[] = array('volume' => 67, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 1);
$data[] = array('volume' => 85, 'edition' => 6);
$data[] = array('volume' => 98, 'edition' => 2);
$data[] = array('volume' => 86, 'edition' => 6);
$data[] = array('volume' => 67, 'edition' => 7);

//本例中將把 volume 降序排列,把 edition 升序排列。

//現(xiàn)在有了包含有行的數(shù)組,但是 array_multisort() 需要一個(gè)包含列的數(shù)組,因此用以下代碼來(lái)取得列,然后排序。


// 取得列的列表
foreach ($data as $key => $row) {
    $volume[$key]  = $row['volume'];
    $edition[$key] = $row['edition'];
}

// 將數(shù)據(jù)根據(jù) volume 降序排列,根據(jù) edition 升序排列
// 把 $data 作為最后一個(gè)參數(shù),以通用鍵排序
array_multisort($volume, SORT_DESC, $edition, SORT_ASC, $data);
?>

傳送門:
http://tw1.php.net/manual/en/...

假灑脫 回答

const echarts = require('echarts');
require('echarts-gl');
const KnowledgeOPs = echarts.init(document.getElementById('containerKG'));
這樣寫就不會(huì)報(bào)錯(cuò)了

吢涼 回答

go-micro微服務(wù)框架,自己編程實(shí)現(xiàn)一個(gè)要好些吧

冷咖啡 回答
  1. debouncethrottle是目前用得最廣泛的,具體可見(jiàn)樓上的一堆收藏;
  2. 想要確保邏輯上不會(huì)有同時(shí)提交的請(qǐng)求,npm搜“mutex”也有很多;
  3. 或者我也寫了一個(gè)簡(jiǎn)易版的,用下面的函數(shù)包裹點(diǎn)擊回調(diào),如果前一次請(qǐng)求尚未結(jié)束,新請(qǐng)求會(huì)和舊請(qǐng)求一起返回。這樣的話回調(diào)要返回Promise

    const debounceAsync = originalFunction => {
      let currentExcution = null;
      const wrappedFunction = async function () {
        // 1. locked => return lock
        if (currentExcution) return currentExcution;
    
        // 2. released => apply
        currentExcution = originalFunction.apply(this, arguments);
        try {
          return await currentExcution;
        }
        finally {
          currentExcution = null;
        }
      };
      return wrappedFunction;
    };

    用法

    const sleep = (ms = 0) => new Promise(resolve => setTimeout(resolve, ms));
    
    const debounceAsync_UNIT_TEST = async () => {
      const goodnight = debounceAsync(sleep);
      for (let i = 0; i < 8; i++) {
        goodnight(5000).then(() => console.log(Date()));
        await sleep(500);
      }
      console.warn('Expected output: 8 identical datetime');
    };

    https://segmentfault.com/a/11...

心沉 回答

find({'value': /^.{0,5}$/, 'key': name})

命多硬 回答
  1. 封裝下請(qǐng)求,過(guò)期跳轉(zhuǎn)
  2. 全局的路由攔截,每次檢查下 session 是否存在
巴扎嘿 回答

三元可以嗎?

{item.columns.count?item.columns.count:0}

你這個(gè)能顯示正確嗎?
如果obj是這樣,{columns.count:99},這么寫

{item["columns.count"]?item["columns.count"]:0}
青裙 回答

你如果是自己直接調(diào)用API的話,你的組件里就會(huì)有很多ajax調(diào)用,組件和action耦合了,個(gè)人看法

朕略傻 回答

走在路上,突然想到了這是什么問(wèn)題。。

var oScript = document.createElement("script"); 
oScript.src = 'http://suggestion.baidu.com/su?wd=' + this.value + '&cb=solve';
document.body.appendChild(oScript);

script在標(biāo)簽插入DOM中才向baidu請(qǐng)求數(shù)據(jù),請(qǐng)求到數(shù)據(jù),會(huì)調(diào)用solve回調(diào)函數(shù),但當(dāng)前全局作用域中沒(méi)有solve函數(shù),所以會(huì)執(zhí)行失敗。。

好難瘦 回答

首先,高流量場(chǎng)景下,不會(huì)有這種 30 分鐘的東西。
其次,這類 30 分鐘的東西,如果未完成,在設(shè)計(jì)上是會(huì)重跑的。

毀了心 回答

你應(yīng)該用一個(gè)RadioGroup來(lái)管理RadioButton的選中和取消,而不用點(diǎn)擊事件來(lái)管理,你這樣邏輯非常亂而且擴(kuò)展性很差

心癌 回答
  1. 把值取出來(lái)
  2. 合并數(shù)據(jù)array_merge
乞許 回答

我寫了一個(gè)demo,在你那上面精簡(jiǎn)了不少,思路就是這樣,你運(yùn)行看看效果:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>example</title>
</head>
<body>
    <div id="app">
        <div class="total">
            <span>總共  {{totalCount}}  道</span>
            <span>合計(jì): ¥  {{totalPrice}}</span>
            <p>選擇的折扣:<span>{{selectDiscount}}</span></p>
            折后金額:<span>{{afterDiscount}}</span>
            <p>選擇折扣:</p><span v-for="item in discount" :key="item.id" @click="addDiscount(item)" style="cursor:pointer;"> {{item.name}}</span>
        </div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script type="text/javascript">
        new Vue({
            el: "#app",
            data: {
                totalCount: 5,
                totalPrice: 155.24,
                selectDiscount: null,
                discount: [{
                    id: 1,
                    name: 0.9
                }, {
                    id: 2,
                    name: 0.8
                }, {
                    id: 3,
                    name: 0.7
                }, {
                    id: 4,
                    name: 0.6
                }, {
                    id: 5,
                    name: 0.5
                }, {
                    id: 6,
                    name: 0.4
                }]
            },
            computed: {
                afterDiscount() {
                    return (this.totalPrice * this.selectDiscount).toFixed(2);
                }
            },
            methods: {
                addDiscount(item) {
                    return this.selectDiscount = item.name;
                }
            }
        })
    </script>
</body>
</html>