-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inicializar declarativamente un componente de JavaScript
1.-se creao nuevo archivo vue-test que contendra el script js correspondiente al vue que se encuentra el template vue-test.phtml 2.- se elimin script correspondiente a vue js y se agrego nuevo tipo x-magento-init Este tipo de declaracion se usa para modulos con script mas grandes o simplemente para hacer un modulo mas flexible al extraer el script del tamplate
- Loading branch information
1 parent
a503f1b
commit 153b463
Showing
2 changed files
with
20 additions
and
9 deletions.
There are no files selected for viewing
16 changes: 7 additions & 9 deletions
16
code/JavaScriptDev/JsFun/view/frontend/templates/vue-test.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
<div id="vue-test"> | ||
<h1>{{ message }}</h1> | ||
</div> | ||
<script> | ||
require(['vue'],function(Vue){ | ||
'use strict' | ||
new Vue({ | ||
el:'#vue-test', | ||
data:{ | ||
message : 'This is test LuisPC ' | ||
<script type="text/x-magento-init"> | ||
{ | ||
"#vue-test":{ | ||
"JavaScriptDev_JsFun/js/vue-test":{ | ||
"message":"Declarative text" | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
define(['vue'],function(Vue){ | ||
'use strict' | ||
|
||
return function(config){ | ||
return new Vue({ | ||
el:'#vue-test', | ||
data:{ | ||
message : config.message | ||
} | ||
}) | ||
} | ||
|
||
}) |