SearchForm.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script>
  2. import Vue from 'vue'
  3. export default {
  4. props: ['form'],
  5. data() {
  6. return {
  7. template: null,
  8. typed: ""
  9. }
  10. },
  11. methods: {
  12. keyup() {
  13. console.log("search typed", this.typed);
  14. },
  15. submit() {
  16. console.log("search clicked");
  17. }
  18. },
  19. beforeMount() {
  20. // console.log('SearchForm beforeMount');
  21. if(this._props.form){
  22. // console.log('SearchForm beforeMount if this._props.form ok');
  23. this.template = Vue.compile(this._props.form)
  24. // https://github.com/vuejs/vue/issues/9911
  25. this.$options.staticRenderFns = [];
  26. this._staticTrees = [];
  27. this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)));
  28. }
  29. },
  30. mounted(){
  31. // console.log('SearchForm mounted');
  32. Drupal.attachBehaviors(this.$el);
  33. },
  34. render(h) {
  35. // console.log('searchForm render');
  36. if(!this.template){
  37. return h('span', 'Loading ...')
  38. }else{
  39. return this.template.render.call(this)
  40. }
  41. }
  42. }
  43. </script>
  44. <style lang="scss" scoped>
  45. </style>