我在这里四处寻找答案,但已经没有提供的答案适合我。
这是一个有效的演示代码pen.io/figaro/pen/mBvWJa
我的项目很简单,一个带有Vue的单页程序来处理页面路由。我在每个不同的页面上都有一些基于jQuery的内容。当我第一次加载页面时,jQuery插件显示正常。但是当我导航到其他页面时,不会重新加载jQuery插件。自从我想到的钩子之后,我就尝试了所有...钩子,beforeRouteEnter,beforeRouteLeave,更新等,但它们都不起作用。我试过使用this。$ nextTick(function(){},但也不起作用。
jQuery插件是光滑的轮播。是的,我知道有一个官方的vue slick包装器,但是我没有使用CLI。...我的项目只是通过CDN连接了vue和vue路由器,我不知道如何在我的项目中使用它设置(它们的示例适用于单个文件组件)。我不在乎解决方案是hacky还是不是最佳实践,我只需要让Vue在每个页面上加载漂亮的初始化脚本即可。我看到了制作指令或组件的示例,但它们对我来说没有意义,因为它们假设您使用的不是我的单个文件组件。有什么办法吗?
main.js
const NotFoundPage = {
name: "NotFoundPage",
template: "#404-template"
};
const routes = [
{ path: "/", component: Industry },
{ path: "/about", component: My Page },
{ path: "/contact", component: About},
{ path: "*", component: NotFoundPage }
];
const router = new VueRouter({
routes
});
new Vue({
router,
template: "#root-template",
mounted: function() {
this.$nextTick(function () {
})
},
beforeRouteUpdate ( to, from , next ) {
this.$nextTick(function () {
})
},
ready: …Run Code Online (Sandbox Code Playgroud) 我已经整理了一个简单的CRUD应用程序,并且大部分都在工作,但似乎无法弄清楚如何对表列进行排序.我在这里有一个工作演示:http://codepen.io/figaro/pen/MJMqYR
var products = [{
id: 1,
name: 'Angular',
description: 'Superheroic JavaScript MVW Framework.',
price: 900
},
{
id: 2,
name: 'Ember',
description: 'A framework for creating ambitious web applications.',
price: 600
},
{
id: 3,
name: 'React',
description: 'A JavaScript Library for building user interfaces.',
price: 500
}
];
function findProduct(productId) {
return products[findProductKey(productId)];
};
function findProductKey(productId) {
for (var key = 0; key < products.length; key++) {
if (products[key].id == productId) {
return key;
} …Run Code Online (Sandbox Code Playgroud)