app.component
:用于定义一个组件,可以包含模板、样式和逻辑代码。例如:
app.component('myComponent', {
template: '<div>This is my component</div>',
controller: function() {
// controller logic
}
});
app.config
:用于配置应用程序的一些参数或设置。例如:
app.config(function($routeProvider) {
$routeProvider
.when('/home', {
templateUrl: 'home.html',
controller: 'HomeController'
});
});
app.directive
:用于定义一个自定义指令,可以在 HTML 中使用。例如:
app.directive('myDirective', function() {
return {
restrict: 'E',
template: '<div>This is my directive</div>'
};
});
app.mount
:用于将应用程序挂载到指定的 DOM 元素上。例如:
app.mount('#app');
app.unmount
:用于将应用程序从指定的 DOM 元素上卸载。例如:
app.unmount('#app');
app.use
:用于注册插件或中间件到应用程序中。例如:
app.use(myPlugin);