abichinger / vue-js-cron

Renderless Vue.js cron editor
MIT License
73 stars 23 forks source link

vue-js-cron/light error on vue2 #28

Closed yeya closed 1 year ago

yeya commented 1 year ago

Hi

I'm getting the error on vue 2.7.14:

Failed to mount component: template or render function not defined. I tried to install ^1.0.5, got the same error.

abichinger commented 1 year ago

Hey,

I wasn't able to reproduce your issue on codepen: https://codepen.io/abichinger/pen/poQVeWM codepen packages:

Please provide your source code if you need further help.

yeya commented 1 year ago

I see. You have to register cronLight to the global Vue.

My issue is that I tried to use it without registering:

<template>
  <div class="getting-started-light">
    <cron-light v-model="value" @error="error = $event"></cron-light>
    <div class="mt-2 grey--text text--darken-1">cron expression: {{ value }}</div>
  </div>
</template>

<script>
import cronLight from '@vue-js-cron/light'
import '@vue-js-cron/light/dist/light.css'
export default {
  components: { cronLight },
  data() {
    return {
      value: '* * * * *',
      error: '',
    }
  },
}
</script>

Reproduction: https://stackblitz.com/edit/vue2-vue-cli-uudsl8?file=package.json,src%2Fcomponents%2FHelloWorld.vue,src%2Fmain.js

abichinger commented 1 year ago

The Vue2 version of vue-js-cron/light exports the following

const plugin = {
    install,
    component,
    util: core.util
};
export default plugin;

It should be possible to register the component with:

components: { CronLight: cronLight.component },

https://stackblitz.com/edit/vue2-vue-cli-gui23p?file=src%2Fcomponents%2FHelloWorld.vue

yeya commented 1 year ago

Cool! Thanks a lot! Maybe should be added to readme?