在新转换的节点列表上创建地图

时间:2019-05-31 16:54:33

标签: javascript events javascript-events listener

我想知道如何在新转换的节点列表上进行映射并添加调用此方法的单击。selectTab

到目前为止,我已经实现了之前的代码

class TabLink {
    constructor(tabElement) {
        // assign this.tabElement to the tabElement DOM reference
        this.tabElement = tabElement;

        // Get the `data-tab` value from this.tabElement and store it here
        this.tabData = document.querySelector(`.tabElement[data-tab='${element.dataset.tab}']`);

        // We need to find out if a user clicked 'all' cards or a specific category.  Follow the instructions below to accomplish this task:    

        // Check to see if this.tabData is equal to 'all'
        if (data === "all") {
            // If `all` is true, select all cards regardless of their data attribute values
            // this.cards = ;
            return document.querySelectorAll(".card");
        } else {
            // else if `all` is false, only select the cards with matching this.tabData values
            // this.cards = ;
            return document.querySelectorAll(`.card[data-tab = '${data}']`);
        }


        // Map over the newly converted NodeList we just created in our if statement above. Convert each this.cards element into a new instance of the TabCard class. Pass in a card object to the TabCard class. 
        // this.cards = Array.from(this.cards).map();

        // Add a click event that invokes this.selectTab
        // this.tabElement.addEventListener();
    }

最后两个被注释掉的地方是我需要帮助的地方,我还需要知道我是否在上一份工作的正确道路上。

0 个答案:

没有答案