function foo() {
bar();
}
function bar() {
foo();
}
foo();
VM204:1 Uncaught RangeError: Maximum call stack size exceeded
at bar (<anonymous>:1:18)
at foo (<anonymous>:1:18)
at bar (<anonymous>:1:18)
at foo (<anonymous>:1:18)
at bar (<anonymous>:1:18)
at foo (<anonymous>:1:18)
at bar (<anonymous>:1:18)
at foo (<anonymous>:1:18)
at bar (<anonymous>:1:18)
at foo (<anonymous>:1:18)
Кроме того, в вашем случае правильным решением
Кроме того, на мой взгляд более правильным
// types.ts
export interface IAppContext {
api: ApiType, // ???
}
// main.ts
import { createApi } from './services/Api';
import { IAppContext } from './types';
import { createStore } from './store';
const api = createApi(
{ url: '/' },
{
getData: { method: 'get', url: '/data' },
},
);
const context : IAppContext = {
api,
};
const store = createStore(context);
// store.ts
import { IAppContext } from './types';
export function createStore(context: IAppContext) {}
createStore<typeof context>(context);
function createStore<T>(context: T) {}
import { InjectionKey } from 'vue';
import { IAppContext } from './types';
export const APP_CONTEXT_KEY: InjectionKey<IAppContext> = Symbol('context');
// types.ts
import { Api } from './api';
export interface IAppContext {
api: Api,
}
// api.ts
import { createApi } from '@/services/Api';
export const api = createApi(
{ url: process.env.VUE_APP_API_URL },
{
getTodo: { method: 'get', url: '/todos/{id}' },
},
);
export type Api = typeof api;
{
"name": "pug-lodash-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"gulp": "^4.0.2",
"gulp-pug": "^5.0.0",
"pug": "^3.0.2"
},
"dependencies": {
"lodash": "^4.17.21"
}
}
const { src, dest } = require('gulp');
const pug = require('gulp-pug');
const _ = require('lodash');
exports.views = () => {
return src('./src/*.pug')
.pipe(
pug({
data: {
message: 'Hello, world!',
_,
},
}),
)
.pipe(dest('./dist'));
};
h1
=message
h2
=_.camelCase('Foo Bar')
export default {
data() {
return {
hotels: [],
visibleHotels: [],
selected_countries: null,
selected_types: null,
reviews_amount: '',
checked_stars: [],
price_range: '',
};
},
methods: {
applyFilters() {
this.visibleHotels = this.hotels.filter(() => { /* логика фильтрации */ });
},
resetFilters() {
this.selected_countries = null;
this.selected_types = null;
this.reviews_amount = '';
this.checked_stars = [];
this.price_range = '';
this.applyFilters();
},
},
}
<HotelsList :listData="visibleHotels" />
<button type="button" @click="applyFilters()">
<button type="button" @click="resetFilters()">