Vuejs从href标签调用方法

时间:2017-12-17 11:40:40

标签: vue.js

当我尝试从属性调用方法时出现此错误:

  

_vm.url不是函数

当我尝试调用函数时

import pygame as pg


pg.init()
screen = pg.display.set_mode((640, 480))
clock = pg.time.Clock()
FONT = pg.font.Font(None, 40)
BLUE = pg.Color('dodgerblue1')


class Score(pg.sprite.Sprite):

    def __init__(self, pos):
        super(Score, self).__init__()
        self.lives = 3
        self.score = 0
        self.rect = pg.Rect(pos, (1, 1))
        self.update_image()

    def update_image(self):
        height = FONT.get_height()
        # Put the rendered text surfaces into this list.
        text_surfaces = []
        for txt in ('lives {}'.format(self.lives),
                    'score {}'.format(self.score)):
            text_surfaces.append(FONT.render(txt, True, BLUE))
        # The width of the widest surface.
        width = max(txt_surf.get_width() for txt_surf in text_surfaces)

        # A transparent surface onto which we blit the text surfaces.
        self.image = pg.Surface((width, height*2), pg.SRCALPHA)
        for y, txt_surf in enumerate(text_surfaces):
            self.image.blit(txt_surf, (0, y*height))
        # Get a new rect (if you maybe want to make the text clickable).
        self.rect = self.image.get_rect(topleft=self.rect.topleft)


def main():
    score = Score((100, 100))
    all_sprites = pg.sprite.Group(score)

    done = False

    while not done:
        for event in pg.event.get():
            if event.type == pg.QUIT:
                done = True
            elif event.type == pg.KEYDOWN:
                if event.key == pg.K_s:
                    # Increment the score and update the image.
                    # It would be nicer to turn the score into a
                    # property and update the image automatically.
                    score.score += 1
                    score.update_image()

        all_sprites.update()
        screen.fill((30, 30, 30))
        all_sprites.draw(screen)

        pg.display.flip()
        clock.tick(30)


if __name__ == '__main__':
    main()
    pg.quit()
<a :href="url(item)" class="link">
    {{ item.label }}
</a>

我做错了什么?

1 个答案:

答案 0 :(得分:5)

该属性为methods,而不是method