PHP 프레임 워크에 대한 vuejs 통합 PHP-VueJS 모든 PHP 프로젝트에 VueJS 추가하고, 기본 또는 PHP Framework 프로젝트 일 수 있습니다.
이 라이브러리를 사용하는 권장 방법은 Composer 사용하는 것입니다. composer.json 에 위치한 디렉토리 에서이 명령을 실행하십시오.
composer require phpmv/php-vuejs주입 된 전체 스크립트를 관리하고 인스턴스화해야합니다.
$ vueManager = VueManager:: getInstance ();vuemanager 방법
$ vue = new VueJs ();vuejs 주장
vuejs 방법
$ component = new VueJSComponent ( ' component-one ' );vuejscomponent argument 's
구성 요소 이름은 Kebab-Case 원칙을 존중해야합니다. 변수 이름을 제공하지 않으면 PascalScase로 변환됩니다.
vuejscomponent 메소드
$ object -> addData ( ' name ' , true );
$ object -> addDataRaw ( ' name ' , ' true ' );AddData, AddDataraw 인수
이 두 줄의 코드는 정확히 동일한 VUE 데이터를 생성합니다.
data: { "name" : true } $ object -> addMethod ( ' greet ' , ' window.alert(`Hello ${name}`); ' ,[ ' name ' ]);추가 메드 인수
아래의 내용이 생성됩니다
methods: {
"greet" :
function ( name ) {
window . alert ( `Hello ${ name } ` ) ;
}
} $ object -> addComputed ( ' reversedMessage ' , " return this.message.split('').reverse().join(''); " );AddComputed 인수
아래의 내용이 생성됩니다
computeds: {
reversedMessage :
function ( ) {
return this . message . split ( '' ) . reverse ( ) . join ( '' ) ;
}
}다음은 Getter and Setter의 예입니다
$ object -> addComputed (
' fullName ' ,
" return this.firstName+' '+this.lastName " ,
" this.firstName=v[0];this.lastName=v[1] " );이 코드는이 컨텐츠를 생성합니다
computeds: {
fullName : {
get : function ( ) {
return this . firstName + ' ' + this . lastName
} ,
set : function ( v ) {
this . firstName = v [ 0 ] ;
this . lastName = v [ 1 ]
}
}
} $ object -> addWatcher (
" title " ,
" console.log('Title change from '+ oldTitle +' to '+ newTitle) " ,
[ ' newTitle ' , ' oldTitle ' ]);부가 된 논쟁
아래의 내용이 생성됩니다
watch: {
"title" :
function ( newTitle , oldTitle ) {
console . log ( 'Title change from ' + oldTitle + ' to ' + newTitle )
}
}주어진 수명주기에서 함수를 실행하는 데 사용할 수있는 모든 방법입니다.
모든 후크는 동일한 방식으로 작동하며 아래의 예는 각 후크에 적용될 수 있습니다.
논쟁을 고리합니다
$ object -> onCreated ( " console.log('Page has been created !'); " );아래의 내용이 생성됩니다
created:
function ( ) {
console . log ( 'Page has been created !' ) ;
}adddirective, addglobaldinipication Arguments
$ object -> addDirective ( ' focus ' ,[ ' inserted ' => " el.focus() " ]);아래의 내용이 생성됩니다
directives: {
focus : {
inserted :
function ( el , binding , vnode , oldVnode ) {
el . focus ( )
}
}
} $ vueManager -> addGlobalDirective ( ' focus ' ,[ ' inserted ' => " el.focus() " ]);아래의 내용이 생성됩니다
Vue . directive ( 'focus' , {
inserted :
function ( el , binding , vnode , oldVnode ) {
el . focus ( )
}
} ) ;AddFilter, AddGloBalfilter 인수
$ object -> addFilter (
' capitalize ' ,
" if(!value){ "
. " return ''; "
. " } "
. " value = value.toString(); "
. " return value.charAt(0).toUpperCase() + value.slice(1); " ,
[ " value " ]);아래의 내용이 생성됩니다
filters: {
capitalize : function ( value ) {
if ( ! value ) { return '' ; }
value = value . toString ( ) ;
return value . charAt ( 0 ) . toUpperCase ( ) + value . slice ( 1 ) ;
}
} $ vueManager -> addGlobalFilter (
' capitalize ' ,
" if(!value){ "
. " return ''; "
. " } "
. " value = value.toString(); "
. " return value.charAt(0).toUpperCase() + value.slice(1); " ,
[ " value " ]);아래의 내용이 생성됩니다
Vue . filter ( 'capitalize' ,
function ( value ) {
if ( ! value ) { return '' ; }
value = value . toString ( ) ;
return value . charAt ( 0 ) . toUpperCase ( ) + value . slice ( 1 ) ;
} ) ;AddComponent, addglobalcomponent, importComponentObject 인수
$ component = new VueJSComponent ( ' component-one ' );
$ component -> addData ( ' framework ' , ' ubiquity ' );
$ vue -> addComponent ( $ component );아래의 내용이 생성됩니다
components: { "component-one" : ComponentOne } $ component = new VueJSComponent ( ' component-one ' );
$ component -> addData ( ' framework ' , ' ubiquity ' );
$ vueManager -> importComponentObject ( $ component );아래의 내용이 생성됩니다
const ComponentOne = {
data :
function ( ) {
return { framework : "ubiquity" }
}
} ; $ component = new VueJSComponent ( ' component-one ' );
$ component -> addData ( ' framework ' , ' ubiquity ' );
$ vueManager -> addGlobalComponent ( $ component );아래의 내용이 생성됩니다
Vue . component ( 'component-one' , {
data :
function ( ) {
return { framework : "ubiquity" }
}
} ) ;AddMixin, Addglobalmixin 인수
$ mixin = new VueJSComponent ( ' mixin-one ' );
$ mixin -> addData ( ' framework ' , ' ubiquity ' );
$ vue -> addMixin ( $ mixin );아래의 내용이 생성됩니다
mixins: [ MixinOne ] $ mixin = new VueJSComponent ( ' mixin-one ' );
$ mixin -> addData ( ' framework ' , ' ubiquity ' );
$ vueManager -> addGlobalMixin ( $ mixin );아래의 내용이 생성됩니다
Vue . mixin ( {
data :
function ( ) {
return { framework : "ubiquity" }
}
} ) ;addglobalextend는 인수를 확장합니다
$ component = new VueJSComponent ( ' component ' );
$ componentOne = new VueJSComponent ( ' component-one ' );
$ componentOne -> addData ( ' framework ' , ' ubiquity ' );
$ componentOne -> extends ( $ component );
$ vueManager -> addGlobalComponent ( $ componentOne );아래의 내용이 생성됩니다
extends: "Component" $ extend = new VueJSComponent ( ' extend-one ' );
$ extend -> addData ( ' framework ' , ' ubiquity ' );
$ vueManager -> addGlobalMixin ( $ extend );아래의 내용이 생성됩니다
Vue . extend ( {
data :
function ( ) {
return { framework : "ubiquity" }
}
} ) ;addglobalobservable 인수
$ vueManager -> addGlobalObservable ( " state " , [ " count " => 0 ]);아래의 내용이 생성됩니다
const state = Vue . observable ( { count : 0 } ) ; Axios를 활성화합니다
$ vueManager -> setAxios ( true );setinheritattrs를 활성화합니다
$ component -> setInheritAttrs ( true );세트 모델 인수
$ component -> setModel ( ' checked ' , ' change ' );AddVue 인수
$ vueManager -> addVue ( $ vue );