tonyfromundefined / nuxt-serverless

Nuxt.js Serverless SSR Starter on AWS (Lambda + API Gateway + S3) with Serverless Framework
254 stars 32 forks source link

Client side events after page render #4

Closed niom closed 5 years ago

niom commented 5 years ago

serving pages with with lambda is wonderful idea and now that I have played with this I've faced a problem with client side events.

So using the template directly and adding a simple button to the page and try click and triggering either data increment event or a method, for some reason nothing will happens.

index.vue

<template>
  <div>
    <h1>Nuxt Serverless Template {{ this.version }}</h1>
    <p>Say Hello to Node.js 8.10 in AWS Lambda</p>
    <router-link to="/hello">hello</router-link>
    <router-link to="/world">world</router-link>
    <button v-on:click="counter += 1">Add 1</button><!--button-->
    <p>The button above has been clicked {{ counter }} times.</p> <!--label to change when event pccurs-->
  </div>
</template>
<script lang="ts">
import { Component, Vue, Provide } from "nuxt-property-decorator";
import { State } from "vuex-class";

export default class Index extends Vue {
  @State((state) => state.version) private version: string;
  @Provide() counter = 1; //data section with counter

}
</script>

After the application is deployed and rendered through lambda the button does not do anything.

yarn sls:deploy

Same also happens when the application is started to locally

yarn start

Any idea why the client side does not do anything after the page has been rendered?

tonyfromundefined commented 5 years ago

provide is not reactive.

https://vuejs.org/v2/api/#provide-inject