当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript vue.nextTick函数代码示例

本文整理汇总了TypeScript中vue.nextTick函数的典型用法代码示例。如果您正苦于以下问题:TypeScript nextTick函数的具体用法?TypeScript nextTick怎么用?TypeScript nextTick使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了nextTick函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should be able to binding primitive method', done => {
    @Component({
      template:
        '<div><div id="text">{{text}}</div><button id="btn" v-on:click="greet">Greet</button></div>'
    })
    class Foo {
      text: string

      constructor() {
        this.text = 'foo'
      }

      greet() {
        this.text = 'hello foo!'
      }
    }

    const vm = new Foo()['$mount']()

    // first state
    expect(vm['$el'].querySelector('#text').textContent).to.contain('foo')

    // click
    vm['$el'].querySelector('#btn').click()

    // after click
    Vue.nextTick(() => {
      expect(vm['$el'].querySelector('#text').textContent).to.contain(
        'hello foo!'
      )
      done()
    })
  })
开发者ID:budiadiono,项目名称:vue-typed,代码行数:33,代码来源:methods.ts

示例2:

    const close = () => {
        dialog.show = false;
        dialog.clear();

        if (afterClose) {
            Vue.nextTick(afterClose);
        }
    };
开发者ID:rectification,项目名称:circuitlab,代码行数:8,代码来源:dialog-controller.ts

示例3: it

    it ('should render correct contents', done => {
        const vm = ctor({ name: 'Vue' });
        expect(vm.txtName).eq('Vue');
        expect(vm.$el.querySelector('input').type).eq('text');
        expect(vm.$el.querySelector('h3.result').textContent).eq('');

        vm.result = "Bye Vue";

        Vue.nextTick(() => {
            expect(vm.$el.querySelector('h3.result').textContent).eq('Bye Vue');
            done();
        });
    })
开发者ID:ServiceStack,项目名称:Templates,代码行数:13,代码来源:Home.spec.ts

示例4: it

  it('should take normal methods and getter setter', done => {
    @Component({
      template:
        '<div><div id="text">now: <span id="now">{{val}}</span>, next: <span id="next">{{next}}</span></div><button id="btn" v-on:click="inc">Inc</button></div>'
    })
    class Foo {
      val: number

      constructor() {
        this.val = 1
      }

      inc() {
        this.val += 1
      }

      get next() {
        return this.val + 1
      }
    }

    const vm = new Foo()['$mount']()

    // initial state
    expect(
      vm['$el'].querySelector('#now').textContent,
      'now 1st state'
    ).to.contain('1')
    expect(
      vm['$el'].querySelector('#next').textContent,
      'next 1st state'
    ).to.contain('2')

    // click
    vm['$el'].querySelector('#btn').click()

    Vue.nextTick(() => {
      // clicked
      expect(
        vm['$el'].querySelector('#now').textContent,
        'now 2nd state'
      ).to.contain('2')
      expect(
        vm['$el'].querySelector('#next').textContent,
        'next 2nd state'
      ).to.contain('3')

      done()
    })
  })
开发者ID:budiadiono,项目名称:vue-typed,代码行数:50,代码来源:computed.ts

示例5: enter

    async function enter(el: HTMLElement, done: () => void) {
        // 临时元素的背景色和波形展示面板背景色相同
        transitionEl!.style.backgroundColor = window.getComputedStyle(el).backgroundColor;
        // 临时面板放置在初始点
        Object.assign(transitionEl!.style, start);

        await Vue.nextTick();

        /** 面板的大小和位置 */
        const backgeoundRect = el.getClientRects()[0];
        /** 起始点的位置 */
        const startRect = transitionEl!.getClientRects()[0];
        /** 圆周变换的半径 */
        const maxRadius = getDiagonal(
            [backgeoundRect.left, backgeoundRect.top],
            [startRect.left, startRect.top],
        );

        // 临时 DOM 的宽度和高度是面板起点和变换起点之差的两倍
        transitionEl!.style.width = Math.abs(backgeoundRect.left - startRect.left) * 2 + 'px';
        transitionEl!.style.height = Math.abs(backgeoundRect.top - startRect.top) * 2 + 'px';
        // 临时 DOM 的左上角顶点坐标与面板重合
        transitionEl!.style.left = backgeoundRect.left + 'px';
        transitionEl!.style.top = backgeoundRect.top * 2 + 'px';
        // 裁剪的初始状态为 0
        transitionEl!.style.clipPath = 'circle(0)';

        await delay();

        // 裁剪结束状态为变换半径
        transitionEl!.style.clipPath = `circle(${maxRadius}px)`;

        await delay(unfoldTime);

        // 展开面板但还未显示时的回调
        if (beforeShow) {
            beforeShow();
        }

        // 设置本体元素的动画
        el.style.opacity = '1';
        el.style.transition = `opacity ${showTime}ms linear`;

        await delay(showTime);

        done();
    }
开发者ID:rectification,项目名称:circuitlab,代码行数:47,代码来源:unfold.ts

示例6: is

export const loadPatch = ({ commit, state }, key?: string) => {
  let patch: PatchState;

  key = key || state.patchKey;     // load a specific patch, or whatever current key is (from localStorage)

  if (key && state.patches[key]) {
    patch = state.patches[key];
    commit('SET_KEY', key);
  } else {
    let fromStorage;
    const base = { name: localStorage.getItem(_NAME) || DEFAULT.name };

    try {
      fromStorage = [_ID, _MODULES, _CONNECTIONS, _PARAMETERS].reduce((acc, k) => {
        const value = localStorage.getItem(k);

        if (value) { acc[k] = JSON.parse(value); }
        return acc;
      }, base);
    } catch (err) { /*  */ }

    patch = Object.assign({}, DEFAULT, fromStorage);
  }

  console.log('%c Loading patch: %s ', 'background:#666;color:white;font-weight:bold;', patch.name || '(localStorage)');

  // NOTE: we cannot load modules, connections, and parameters all at once.
  //       Modules must be mounted first, so that all AudioNodes are available
  //       to the Connections; likewise the Modules' settings need to be
  //       available before Parameters are instantiated.
  commit('LOAD_PATCH', patch);      // loads: id, name, modules, and parameterSets. NO connections / parameterKey
  commit('LOAD_CONNECTIONS', []);   // first, explicitly destroy all connections
  commit('SET_PARAMETERS_KEY', -1); // and temp unset this so that it'll trigger a mutation on next tick

  // ensure nodes (+ inlets/outlets) are in the DOM...
  Vue.nextTick(() => {
    // ...then load new connections
    console.log('%c Routing audio... ', 'background:#666;color:white;font-weight:bold;');
    commit('LOAD_CONNECTIONS', patch.connections);

    // ...lastly, load parameters
    console.log('%c Setting parameters... ', 'background:#666;color:white;font-weight:bold;');
    commit('SET_PARAMETERS_KEY', 0);
  });
};
开发者ID:apathetic,项目名称:modular-synth,代码行数:45,代码来源:actions.ts

示例7: createId

        await Promise.all(lines.map(async (storage) => {
            const lineData: LineData = {
                type: LineType.Line,
                id: createId('line'),
                connect: ['', ''],
                way: LineWay.from(storage.way),
            };

            markId(lineData.id);
            commit(MutationName.PUSH_LINE, lineData);

            await Vue.nextTick();

            const line = findLineComponent(lineData.id);

            line.setConnectByWay();
            line.markSign();
            line.dispatch();
        }));
开发者ID:rectification,项目名称:circuitlab,代码行数:19,代码来源:index.ts

示例8: test

test('update use href with expression', () => {
  const vm = new Vue({
    data: { icon: 'icons1' },
    render(h) {
      return h('div',
        [h('svg', {
          directives: [{ name: 'svg', value: this.icon }],
        })]
      );
    },
  }).$mount();

  // Change state and wait for one tick until checking
  vm.icon = 'icon2';
  Vue.nextTick(() => {
    const href = vm.$el.querySelector('use').getAttribute('href');
    const xlinkHref = vm.$el.querySelector('use').getAttribute('xlink:href');

    expect(href).toBe('/assets/svg/sprite.svg#icon2');
    expect(xlinkHref).toBe('/assets/svg/sprite.svg#icon2');
  });
});
开发者ID:thierrymichel,项目名称:vue-svg-sprite,代码行数:22,代码来源:index.test.ts

示例9: Matrix

        await Promise.all(parts.map(async (storage) => {
            const partData: PartData = {
                type: storage.type,
                id: storage.id,
                params: storage.params || [],
                rotate: storage.rotate
                    ? Matrix.from(storage.rotate)
                    : new Matrix(2, 'E'),
                position: Point.from(storage.position),
                connect: [],
            };

            commit(MutationName.PUSH_PART, partData);

            await Vue.nextTick();

            const part = findPartComponent(partData.id);

            if (storage.text) {
                if (storage.text === 'top') {
                    part.textPosition = new Point(0, -100);
                }
                else if (storage.text === 'right') {
                    part.textPosition = new Point(100, 0);
                }
                else if (storage.text === 'bottom') {
                    part.textPosition = new Point(0, 100);
                }
                else if (storage.text === 'left') {
                    part.textPosition = new Point(100, 0);
                }

                part.renderText();
            }

            part.markSign();
        }));
开发者ID:rectification,项目名称:circuitlab,代码行数:37,代码来源:index.ts

示例10: bind

import * as Stickyfill from "stickyfilljs";
import Vue from "vue";

export default Vue.directive("stickyfill", {
  bind(el: HTMLElement) {
    el.style.position = "sticky";
    el.style.top = "75px";
    Vue.nextTick(() => Stickyfill.add(el));
  },
  unbind(el: HTMLElement) {
    Stickyfill.remove(el);
  }
});
开发者ID:kevmo314,项目名称:canigraduate.uchicago.edu,代码行数:13,代码来源:Sticky.ts


注:本文中的vue.nextTick函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。