-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integration with VueJS + Typescript possible ? #113
Comments
Hi @lodacom, It seems a This error Also, you can share the |
Hi @marconi1992, Thanks you for your reply. import {Vue, Component, Prop, PropSync} from "vue-property-decorator";
import ButtonModel from "../../models/buttonModel"
import {CreateElement, VNode} from "vue";
import VueBis from 'vue';
import './Button.css';
const template = `
<div>
<div v-bind:class="_model.type+'Button '+_model.buttonColor+'Button' + ' container-align'" @click="action" v-bind:style="'width:'+ _model.width + ';height:' + _model.height + ';'">
<div v-bind:class="_model.type+'LabelButton '+_model.labelColor+'LabelButton'" >
{{ _model.buttonText }}
</div>
</div>
</div>
`;
const compiledTemplate = VueBis.compile(template);
@Component
export default class Button extends Vue {
@PropSync("model", {type: ButtonModel}) private _model!: ButtonModel;
@Prop(Function) private action!: Function;
constructor () {
super();
}
render(createElement: CreateElement): VNode {
return compiledTemplate.render.call(this, createElement);
}
} And here the model code : export default class ButtonModel {
private _buttonText!: string;
private _labelColor: string;
private _buttonColor: string;
private _type: string;
private _width: string;
private _height: string;
constructor(buttonText: string, width = "", height = "50px", labelColor = 'white', buttonColor = 'redBgRedBorder', type = 'default') {
this._buttonText = buttonText;
this._labelColor = labelColor;
this._buttonColor = buttonColor;
this._type = type;
this._width = width;
this._height = height;
}
get buttonText(): string {
return this._buttonText;
}
set buttonText(value: string) {
this._buttonText = value;
}
get labelColor(): string {
return this._labelColor;
}
set labelColor(value: string) {
this._labelColor = value;
}
get buttonColor(): string {
return this._buttonColor;
}
set buttonColor(value: string) {
this._buttonColor = value;
}
get type(): string {
return this._type;
}
set type(value: string) {
this._type = value;
}
get width(): string {
return this._width;
}
set width(value: string) {
this._width = value;
}
get height(): string {
return this._height;
}
set height(value: string) {
this._height = value;
}
} The Fournisseur component code is too complex to share here. But as I tested a smaller component and it makes the same error, I can share it. Here is the OffreFournisseur : <template>
<div>
<br>
<br>
<br>
<br>
Produits du fournisseur
<div><UgapButton :model="buttonContacter" :action="contacter"/></div>
<br>
<br>
<br>
<br>
<br>
</div>
</template>
<script lang="ts">
import {Vue, Component, Prop} from "vue-property-decorator";
import UgapButton from "@lodacom/vue-components/dist/js/components/atomes/Button/Button";
import ButtonModel from "@lodacom/vue-components/dist/js/components/models/buttonModel";
@Component({
components: {
UgapButton
}
})
export default class OffreFournisseur extends Vue {
@Prop(String) private ongletCourant!:string;
private buttonContacter!: ButtonModel;
constructor(){
super();
const model = new ButtonModel("Contacter", "151px", "45px");
this.buttonContacter = model;
this.$emit("routeChanged", this.ongletCourant);
}
contacter(){
alert("boutton contacter");
}
}
</script>
<style scoped>
</style> Then I replace the Fournisseur component by this one in client and server files. Then as I said I got the error. Could you guide me and/or give me some advices to make my library compatible with SSR if not ? |
I tried to integrate Ara Framework with Typescript and VueJs. My project comes with my own external library.
Here is my webpack config :
When I launch my Ara dev task ("ara:dev": "webpack --config araWebpack.config.js --watch --mode development"), it's crashed with this mysterious error :
webpack:///./node_modules/vue/dist/vue.esm.js?:9227
decoder = decoder || document.createElement('div');
^
ReferenceError: document is not defined
at decode (webpack:///./node_modules/←[4mvue←[24m/dist/vue.esm.js?:9227:26)
at cachedFn (webpack:///./node_modules/←[4mvue←[24m/dist/vue.esm.js?:163:33)
at Object.chars (webpack:///./node_modules/←[4mvue←[24m/dist/vue.esm.js?:9865:50)
at parseHTML (webpack:///./node_modules/←[4mvue←[24m/dist/vue.esm.js?:9388:17)
at parse (webpack:///./node_modules/←[4mvue←[24m/dist/vue.esm.js?:9731:3)
at baseCompile (webpack:///./node_modules/←[4mvue←[24m/dist/vue.esm.js?:11855:13)
at compile (webpack:///./node_modules/←[4mvue←[24m/dist/vue.esm.js?:11830:22)
at Function.compileToFunctions [as compile] (webpack:///./node_modules/←[4mvue←[24m/dist/vue.esm.js?:11713:20)
When I comment the server part in webpack config, client part is generated whithout any issue.
Here is my client.js :
And here is my server.js :
It's seem that the issue is coming from my external library. Like the latter was interpreted twice. I tried to exclude it, but without any effect.
Have you any idea to force this behaviour or to solve this kind of issue in Ara environnement ?
I specify that I didn't encounter this issue when I launch my server without Ara things.
The text was updated successfully, but these errors were encountered: